bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc041.c

luc041.c (623B)


      1 /* Write a program to print 24 hours of day with suitable suffixes like
      2 AM, PM, Noon and Midnight. */
      3 /* Let Us C, Chap- 6, Page - 106, Qn No.: B(h) */
      4 
      5 #include <stdio.h>
      6 int main()
      7 {
      8     int hour, temp;
      9     printf("Time \tSuffix\n");
     10     for (int hour = 0; hour <= 23; hour++)
     11     {
     12         if (hour == 0)
     13             printf("12:00\tAM (Midnight)\n");
     14         else if (hour == 12)
     15             printf("12:00\tPM (Noon)\n");
     16         else if (hour >= 1 && hour <= 11)
     17             printf("%02d:00\tAM\n", hour);
     18         else if (hour >= 13 && hour <= 23)
     19             printf("%02d:00\tPM\n", hour - 12);
     20     }
     21     return 0;
     22 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror