luc041.c
Problem Statement
luc041.c
Write a program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.
Source Code
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
● Author - Amit Dutta · Updated - 12 Dec 2025