Q25 Write a program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.
Program: 118
Write a c program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.
Output:
12 Midnight 1 AM 2 AM 3 AM 4 AM 5 AM 6 AM 7 AM 8 AM 9 AM 10 AM 11 AM 12 Noon 1 PM 2 PM 3 PM 4 PM 5 PM 6 PM 7 PM 8 PM 9 PM 10 PM 11 PM
Can be optimize as:
#include <stdio.h>
int main()
{
int i,j;
printf(“12 Midnight\n”);
for(i=1; i<=11; i++)
printf(“%d AM\n”,i);
printf(“12 NOON\n”);
for(j=1; j<=11; j++)
printf(“%d PM\n”, j);
}