Because the first hour of the day is 1 AM. So when you put in the zeroth hour of the day, it would technically be the 24th hour of the previous day...but then it rolls back over (subtracts the 24 hours). Think about a 24 hour time systems (Americans use a 12 hour clock) like the military and several nations in the world.
00:30 is 12:30 in the morning
12:30 is 12:30 in the evening (or afternoon)
@Volatile Pulse this is the one that i programmed, i can't really express my problems but kindly try this to see what the problem is. :) thanks in advance.
void time ()
{
int hours;
int minutes;
string ampm, choice;
while (1)
{
cout <<"Enter the hour/hours."<<endl;
cin >> hours;
cout<<"Enter the minute/minutes."<<endl;
cin>>minutes;
@Volatile Pulse
wow! thanks. that really helped. :) but another one, our time should be in 24 hour format, that's why it should have the output " 00: 30 AM " instead of " 12:30 AM " :). again thanks for the previews answer. :)
If it's supposed to print out in 24 hour format, your code has a lot of "extras" that you don't need.
You can remove the string ampm and every assignment of it, you can remove the first if/else conditions, you second if should be less than 0, greater than 23, your third if should be greater than 59 less than 0, your fourth one can be removed altogether, and you should have the output only displayed if the user didn't enter "Invalid" times. Also, you need to move setw(2) and setfill('0'); to the beginning of the cout line.