/* * This file is time.c -- a program written in the C programming language. * Notice that the file extension is a lowercase c. * * This program practices with I/O in C. The user enters hour, minute * and am/pm character, and the program prints out the time in a * standard format. * * Most C programs do "standard I/O", so we include stdio.h. By * "standard" I/O, we mean that the input comes from the keyboard * and the output goes to the screen. */ #include main() { int hour, minute; char am_pm; printf ("Please enter the hour number (1-12): "); scanf ("%d", &hour); printf ("Please enter the minute number (0-59): "); scanf ("%d", &minute); printf ("Enter the letter 'a' for am, or 'p' for pm: "); scanf ("%c", &am_pm); printf ("The time you entered is %d:%02d %cm.\n", hour, minute, am_pm); }