Calculating the sum of integers in an array

后端 未结 9 1498
我在风中等你
我在风中等你 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 03:57

    int main()
    {
        //this the sum of integers in an array
        int array[] = { 22,2,2,1,5,4,5,7,9,54,4,5,4 },x,sum=0;
        int cout_elements = sizeof(array) / sizeof(int);
        for (x = 0; x < cout_elements; x++) {
            
            sum += array[x];
    
        }
        printf("%d",sum);
        return 0;
    }
    

提交回复
热议问题