C语言for (int i=1;i<=count;i++)编译不通过。 5
教科书上面照打出来的,但是编译不通过。求解。我用的Dev-C++.#include<stdio.h>intmain(void){longsum=0L;intcount=0...
教科书上面照打出来的,但是编译不通过。求解。我用的Dev-C++.
#include<stdio.h>
int main(void)
{
long sum=0L;
int count=0;
printf("\nEnter the number of intergers you want to sum :");
scanf("%d",&count);
for (int i=1;i<=count;i++)
sum+=i;
{
printf("\nTotal of the first %d numbers is %ld\n",count,sum);
return 0;
} 展开
#include<stdio.h>
int main(void)
{
long sum=0L;
int count=0;
printf("\nEnter the number of intergers you want to sum :");
scanf("%d",&count);
for (int i=1;i<=count;i++)
sum+=i;
{
printf("\nTotal of the first %d numbers is %ld\n",count,sum);
return 0;
} 展开
2个回答
展开全部
少了一个括号},
int main(void)
{
long sum=0L;
int count=0;
printf("\nEnter the number of intergers you want to sum :");
scanf("%d",&count);
for (int i=1;i<=count;i++)
sum+=i;
{
printf("\nTotal of the first %d numbers is %ld\n",count,sum);
return 0;
}
}
int main(void)
{
long sum=0L;
int count=0;
printf("\nEnter the number of intergers you want to sum :");
scanf("%d",&count);
for (int i=1;i<=count;i++)
sum+=i;
{
printf("\nTotal of the first %d numbers is %ld\n",count,sum);
return 0;
}
}
追问
补了括号,for (int i=1;i<=count;i++)
还是编译不通过。求解
追答
long sum=0L; 改为long sum=0; 注意标点符号必须是英文输入法
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询