C Program to Find Sum of 1 to 100
You can use a loop to calculate the sum of numbers from 1 to 100. Here is the specific code:
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
}
printf("1到100的和为:%d\n", sum);
return 0;
}
The code above utilizes a for loop to add numbers from 1 to 100, ultimately outputting the sum of all numbers from 1 to 100.