I don’t know if I’m just a complete fool, most likely I, it was a long day, but it doesn’t work as I want, and, well, I don’t see why.
It should be able to enter 11 numbers, a new number on each line, add them to the array, and then sum them, but it just doesn't work. It does not stop to exit the loop, although I increase i.
Any ideas?
int main(void) {
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 += array[i];
}
printf("%d", sum);
return 0;
}
source
share