本题要求编写程序,计算表达式 1 + 2 + 3 + … + 100 的值。
输入格式:
本题无输入。
输出格式:
按照以下格式输出:
sum = 累加和
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i=0,sum=0;
for(i=0;i<=100;i++)
{
sum+=i;
}
printf("sum = %d",sum);
return 0;
}