luc041.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
Write a program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
int main()
{
int hour, temp;
printf("Time \tSuffix\n");
for (int hour = 0; hour <= 23; hour++)
{
if (hour == 0)
printf("12:00\tAM (Midnight)\n");
else if (hour == 12)
printf("12:00\tPM (Noon)\n");
else if (hour >= 1 && hour <= 11)
printf("%02d:00\tAM\n", hour);
else if (hour >= 13 && hour <= 23)
printf("%02d:00\tPM\n", hour - 12);
}
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18