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

Popular posts from this blog

Write a program to check if a number is prime or not.

Write a program to print the grades to a student.

write a program (keep taking numbers as input from user until user enters an Odd number)