/*计算1+2+3+…+n*/
#include<stdio.h>
int main(void)
{
int i,n,sum;
printf("Enter n:");
scanf("%d",&n);
sum=0;
for(i=1;i<=n;i++){
sum=sum+i;
}
/*输入累加和*/
printf("Sum of numbers from 1 to %d is %d\n,",n,sum);
return0;
}
posted on
2013-10-05 17:51yy99
阅读(74)
评论(0)
编辑收藏举报