CJCoding With Joseph
15free / daySign inCreate account

Twelve-Hour Clock

The array hours holds several hours in 24-hour time (0 to 23), and minute holds the minute shared by all of them. For each hour print the time in 12-hour form h:mm AM or h:mm PM: hour 0 is 12 AM, 1 to 11 keep their number with AM, 12 is 12 PM, and 13 to 23 subtract 12 and use PM. Minutes under 10 need a leading zero. Use if statements for the period, the hour conversion and the zero padding, one line per hour.

Expected Output:

12:05 AM
9:05 AM
12:05 PM
2:05 PM
11:05 PM

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
If Statements
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.