2016-10-31 50 views

回答

2

while (i <= n); - >while (i <= n)。丢掉;。使用;while()循环永不结束,并且从不输入{ scanf("\n%d", &a); ...

建议使用自动格式 - 容易发现这样的问题。


另外,读取n值使用<@BLUEPIXY

// while (i <= n) 
while (i < n) 
0

@Shabnam可以使用此代码

#include <stdio.h> 
int main() 
{ 
    int n, sum = 0, c, value; 

    printf("Enter the number of integers you want to add\n"); 
    scanf("%d", &n); 

    printf("Enter %d integers\n",n); 

    for (c = 1; c <= n; c++) 
    { 
    scanf("%d", &value); 
    sum = sum + value; 
    } 

printf("Sum of entered integers = %d\n",sum); 

return 0; 
} 
相关问题