第1个回答 推荐于2017-10-11
#include <stdio.h>
int main (void)
{
long sum=0;
int count,i;
printf("\nEnter the number of integers you want to sum:");
scanf("%d",&count);
for( i=1;i<count||i==count;i++)
/* [Error] 'for' loop initial declarations are only allowed in C99 mode 我估计意思是在for()中定义变量,只能在C99标准里*/
sum +=i;
printf("\nTotal of the first %d number is %Ld\n",count,sum);
return 0;
}本回答被提问者和网友采纳
第2个回答 2013-11-18
#include <stdio.h>
int main ()//无需void
{
long int sum=0;//这才是长整形变量
int count;//无需赋值,但不为错,会被掩盖
printf("\nEnter the number of integers you want to sum:");
scanf("%d",&count);
for(int i=1; i <= count;i++)
sum+=i;
printf("\nTotal of the first %d number is %ld\n",count,sum);
return 0;
}