Calculating the sum of integers in an array

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

    You have problems with your array declaration. You are defining an array of size 10 array[10] and saying the program to calculate the sum of 11 elements which is resulting in memory overflows.

    To correct the program just increase size of the array as array[11]. Also if you wish you can check the recursive approach to find sum of array elements.

提交回复
热议问题