Hi all, I'm writing a program to calculate the average of 10 integer numbers (which is easy). I have to use an array to store all 10 integers (easy again) but the issue that I'm having is that if the user enters any letter the program should calculate the average at that point. In other words if the user enters 5 integers and then enters a letter the program should calculate the average of those 5 integers and end.
What kind of "if" statement should I write? The array that holds the user's input is int values[10]. I'm trying to use this if statement but I get garbage output:
if (values[i]=='x') {store the value of i and proceed to find the average}
And that's after using a loop with index i. Again, the issue Im having is telling the computer to stop after the user enters a letter.
Any help would be appreciated, thanks.