Come on, think. :) This is very easy. How do we convert from 24h notation to 12? When someone says it's 23:00 you know, it is 11:00 pm, or 22:00 is 10:00 pm 21:00 is 9, 20:00 is 8.
24 -> 0
23 -> 11
22 -> 10
21 -> 9
20 -> 8
19 -> 7
18 -> 6
Look at the difference between 23 and 11, 22 and 10 and so on. It's always 12. You only need to subtract 12. It is slightly more elegant to do it with the modulo operator.
22 % 12 = 10
21 % 12 = 9
24 % 12 = 0;
LRRR
Junior Poster in Training
55 posts since Dec 2011
Reputation Points: 22
Solved Threads: 15
Skill Endorsements: 0
Will your input be a time_t or some other time structure?
Will it be a string that is input by the user?
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
OP clearly has no intention of doing any work, which means this violates our homework rule. Thread closed.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54