0

Can someone help me write a code in C++ to convert a 12 hour format clock into 24 hour format ?

The clock accepts the Input as = 02:45 PM And the respective Output must be = 14:45

26th Jun 2020, 7:01 AM
Deepak Singh
Deepak Singh - avatar
4 Respuestas
+ 2
Hint: Check the last 2 character. If it says 'PM' then work on it. Otherwise ignore it. Find the colon position, and see if the distance between the colon and string beginning makes sense to hold a number. Otherwise you have garbage (or nothing) where the hour should be. Extract the hour part from the input and convert it into a number. Don't forget to check that it is within 24 hours range tops. Once you get to this point, all there is to do was just to add 12 to the hour, and you can display the output.
26th Jun 2020, 7:10 AM
Ipang
26th Jun 2020, 7:21 AM
Deepak Singh
Deepak Singh - avatar