Can array be used to store values input by the user if there is no specific number of values to store?
I have this program and I want to know what mistakes I did in the loop ( I know there are quite a few.. ) I tried to run it and it actually did except it hung after the prompting for the user values.
I have no clue why it hung....
//This program asks the user to input the number of values to average
//and each of the values and then outputs the average
using namespace std;
int main ()
int n = 0, i = 0, avg = 0, num = 0;
cout << "Enter the number of values to average: ";
cin >> n;
while ( n > 0);
cout << "Enter value for" << i + 1 << " : ";
cin >> num;
avg = ( num + num )/n;
cout << "Average = " << avg << endl;
Any ideas on what loop is best to use? For loops wouldn't work since there is no specific number of times for the looping, would it?