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

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

One thought on “Q25 Write a program to print 24 hours of day with suitable suffixes like AM, PM, Noon and Midnight.

  • August 24, 2022 at 6:19 pm
    Permalink

    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);
    }

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.