Hello, and thanks for any help in advance!
Basically, as the title says, I am looking for a way to print the number of times the user gave the program an input, and then also print the average of all the inputs.
So far, I have initialized three variables as follows:
Do I need to use a loop to do this? I have also written the expressions for the three variables:
I have tried printing the values of counter and average, and I get a negative counter value and a nonense average value.
So, in summary, do I need a loop to print the number of inputs and their average? Also, using a loop or not, how do I get the second three lines of code to work correctly?
Thank you in advance for any help!!
Basically, as the title says, I am looking for a way to print the number of times the user gave the program an input, and then also print the average of all the inputs.
So far, I have initialized three variables as follows:
Code:
int counter=0; int sum=0; float average=0;
Code:
sum = sum + size; counter = counter + 1; average = sum/counter;
So, in summary, do I need a loop to print the number of inputs and their average? Also, using a loop or not, how do I get the second three lines of code to work correctly?
Thank you in advance for any help!!
Comment