This is my homework. I am asked to write a program that let user input several numbers and then calculate the average of them. I finished most of it, but i don't know how to end the loop by let user enter "done". Can anyone tell me how solve it?
You're making things way more complicated than it needs to be.
The only variables you need are:
1 2 3
int num = 0; //number user enters
int sum = 0; //accumulative sum of numbers
int count = 0; //count of numbers entered
Pseudo-code
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//declare variables, as show above
infinite loop
ask user to enter a number or enter -1 to stop
store input in num
if num is -1
break out of loop //we don't want to increment count and add to sum when user inputs -1 to stop
add num to sum
increment count
print out average //average = sum/count; make sure to cast as float/double, since averages can have decimals