Question about stopping inputs

Hey guys I have a question about some inputs and when to stop.

So I am suppose to have the user input day, the high temperature for the day, the record high temp, the year it was recorded and the humidity percentage. I am suppose to have these sent into an array, and when the user decided to stop entering the data they have to enter 0 into all the fields and quit. I am having trouble doing this and just wanted some advice.

this is currently what my code looks like for that area.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ix = 0;

		do
		{
			cout << endl << "Enter the five data fields. "
				"When you are done enter 0 for all fields." << endl;

			cout << endl << "Enter the day " << endl;
			cout << "(Counting from beginning of year for example: "
				"February 2 is 33): ";
			cin >> day[ix];

			cout << endl << "Enter the high temperature (degrees Fahrenheit): ";
			cin >> highTemp[ix];

			cout << endl << "Enter the record high temperature "
				"(degrees Fahrenheit): ";
			cin >> recordHigh[ix];

			cout << endl << "Enter the year the record high temperature"
				" was recorded: ";
			cin >> yearRecord[ix];

			cout << endl << "Enter the relative humidity (in percent): ";
			cin >> humidityPercent[ix];

			++ix;
		}
		while (day[ix] != 0);


Thanks in advance guys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std ;

int main()
{
    constexpr int MAX = 10 ; // ****
    int day[MAX] ;
    double highTemp[MAX], recordHigh[MAX], yearRecord[MAX], humidityPercent[MAX] ;
    int ix = 0;

    do
    {
        cout << endl << "Enter the five data fields. "
             "When you are done enter 0 for the day." << endl; // ***

        cout << endl << "Enter the day " << endl;
        cout << "(Counting from beginning of year for example: "
             "February 2 is 33): ";
        cin >> day[ix];
        if ( day[ix] == 0 ) break ; // ****

        cout << endl << "Enter the high temperature (degrees Fahrenheit): ";
        cin >> highTemp[ix];

        cout << endl << "Enter the record high temperature "
             "(degrees Fahrenheit): ";
        cin >> recordHigh[ix];

        cout << endl << "Enter the year the record high temperature"
             " was recorded: ";
        cin >> yearRecord[ix];

        cout << endl << "Enter the relative humidity (in percent): ";
        cin >> humidityPercent[ix];

        ++ix;
    }
    while( ix < MAX ) ; // ****
}
Thank you very much.. Helped a lot
Topic archived. No new replies allowed.