Ok so I need to make two for loops. I first one will ask for 10 numbers and then it will print the largest number out of the 10 numbers entered. The second one will also ask for 10 numbers and then calculate the average of all the numbers.
A tip, please do figure the missing lines yourself ;)
1 2 3 4 5 6 7 8 9 10 11
int sumOfAllElements = 0;
for(int i =0; i < 10; i++)
{
cout << " Element #" << i << " is "<< a[i];
// how to get the sumOfAllElements?
// ...
}
int average;
// what to do with sumOfAllElements to get average?
// ...
I do understand how to get to where you are at in the code. But i'm not sure how to make a for loop for this to figure out the largest number out of 10 numbers and average of the 10 numbers (remember this will be two separate programs)
You just keep a running total of entered numbers in an integer. To get an average, you would just then divide by the number of enter numbers, which in this case would be 10.