C Programming language

adplus-dvertising
C Program example: Sum of number using while loop
Previous Home Next
Sum of starting 10 numbers
/** Sum of starting 10 numbers **/

#include<stdio.h>
#include<conio.h>
void main()
{
	int sum,n;
	sum=0;
	n=1;
	clrscr();
	while(n<=10)
	{
		sum=sum+n;
		n=n+1;
	}
	printf("sum=%d\n",sum);
	getch();
}
Output: sum=55
Previous Home Next