I was wondering if someone could tell me what is wrong with this code. I am trying to write a program which will ask the user to enter a time and then add 12 to it if the end char entered is P and the numerical value of the hour is < 12. With the following code, the program adds 12 regardless and I am trying to figure out how to resolve this. Thanks.
Code:cout << "Enter start time (hh:mm A/P): "; float start_hour = 0; float start_minute = 0; char A = 0; char P = 0; char dummy(0); cin >> start_hour >> dummy >> start_minute >> A || P; if ( P && start_hour <12 ); { start_hour = start_hour + 12; }



LinkBack URL
About LinkBacks


