Why am I getting an infinite loop?

I'm a beginner




#include <iostream>

using namespace std;

int inputData();
int convertData();
int outputData();

int main ()
{
inputData();
return 0;
}

int inputData ()
{
int hours, minutes;
char am_pm;

cout << "Please enter hours: "; // ask user to input hours.
cin >> hours;
do
{
if (hours > 23)
{
cout << "ERROR! Must be less than 23" << endl;
}
}
while (hours > 23); // end of hours loop

cout << "Please enter minutes: ";
cin >> minutes;
do
{
if (minutes > 59)
{
cout << "Must be less than 59. Try again!" << endl;
}
}
while (minutes > 59);
}


1
2
3
4
5
6
7
8
do
{
  if (hours > 23)
  {
    cout << "ERROR! Must be less than 23" << endl;
  }
}
while (hours > 23); // end of hours loop 


If hours is bigger than 23, when will this loop end? Point to the line of code, inside the loop, that will change the value of hours.
Topic archived. No new replies allowed.