Home Why do I keep getting an infinite loop?
Reply: 0

Why do I keep getting an infinite loop?

user853
1#
user853 Published in April 26, 2018, 5:20 pm

I keep getting an infinite loop? What do i have to change to fix this? I am a beginner. Please help. I cant figure this out. I tried playing around with all the other loops but keep getting the same error.

#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);
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306624 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO