luc041.c¶
Problem Statement
Write a program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta (amitdutta4255@gmail.com) |
| License | MIT |
Actions¶
💡 You can print or save this file by opening Raw and using your browser.
Source Code¶
#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;
}