Calculating the sum of integers in an array

后端 未结 9 1503
我在风中等你
我在风中等你 2021-01-19 03:11

I don\'t know if I\'m just being a total fool, most likely I am, it\'s been a long day, but this isn\'t working as I want it to, and, well, I don\'t see why.

It sho

9条回答
  •  囚心锁ツ
    2021-01-19 04:09

    Try this:

    void main() {
     int array[10];
     int i;
     int sum = 0;
    
      for ( i = 0; i < 11; i++){
       scanf("%d", &array[i]);
      }
      for (i = 0; i < 11; i++) {
       sum = sum + array[i] ;
      }
    printf("%d", sum);
    
    return 0;
    }
    

提交回复
热议问题