Hello, I am trying to write a program that prompts the user for 12 integers that represent rainfall averages for a year, then prompt the user for 12 more integers that represent actual rainfall for last year. What happens is the first question takes in the integers, but the program ignores the second prompt. I need both sets of numbers in order to output a table that shows the user how much above or below the actual rainfall is. Here are the statements I'm having trouble with:
cout << "\n Enter average rainfall for last 12 months: \n";
cin >> month_ave[0];
cout << "\n Enter actual rainfall for last 12 months: \n";
cin >> month_act[0];
It does not allow the user to enter values for the actual rainfall.
Any help would be appreciated!
If I understand your question correctly - the program only allows you to enter a single number each time?
That's because you are only giving it one memory space to write to:
1 2
cout << "\n Enter average rainfall for last 12 months: \n";
cin >> month_ave[0] >> month_ave[1] >> month_ave[2] //etc
That will allow you to write as many numbers as you need, or you could make a loop:
1 2
for (size_t i=0; i<12; ++i)
std::cin << month_ave[i];