write a program to calculate the sum of all numbers from 1 and 100.
//program to calculate the sum of all numbers from 1 and 100.
#include<stdio.h>
int main()
{
int sum=0;
for(int i=1; i<=100; i++){
sum = sum + i;
}
printf("sum of numbers from 1 to 100 =%d\n", sum);
return 0;
}
output :
sum of numbers from 1 to 100 =5050
--------------------------------
Process exited after 0.006596 seconds with return value 0
Press any key to continue . . .
Comments
Post a Comment
Please do not enter any spam link in the comment box.