Sunday, 11 December 2011

Write a program to print sum of 1,2,…,10 number with while loop in c

#include
#include
main()
{
int i;
int sum=0;
clrscr();
i=1;
while(i<=10)
{
sum=sum+i;
i++;
}
printf("\n The sum of numbers from 1 to 10 is:%d",sum);
getch();
}


OUTPUT

The sum of numbers from 1 to 10 is : 55

No comments:

Post a Comment