the basic idea of what im trying to do is write a program that reads an arbitrary number of integers less than 20. then it prints out the position of the integer in the order the user inputed it then it finds the sum when it scans a non integer character like *. so it would look something like this if it run correctly
36 27 55 -3 42 66 -5 *
Entered integer number 0: was 36
Entered integer number 1: was 27
Entered integer number 2: was 55
Entered integer number 3: was -3
Entered integer number 4: was 42
Entered integer number 5: was 66
Entered integer number 6: was -5
The sum is: 218
i have written this so far
#include <stdio.h>
#define SIZE 20
int main(void)
{
int i = 0;
int array[SIZE];
int sum = 0;
while (scanf("%d", &array[i]) !=0){
printf("Entered Integer number %d: was %d\n", i, array[i]);
i++;
}
int n = SIZE;
for (i = 0; i < n;){
sum = sum + array[i];
printf( "The sum is: %d\n", sum);
}
return 0;
}
it pretty much does the first part of reading out the position of the integers but it goes nuts when its time to find the sum. any help would be appreciated