#include #include #include // Daily Calendar // // Write a complete C program which uses for loops to print a daily calendar of the form given below. // 9:00 a.m. // 9:15 a.m. // 9:30 a.m. // 9:45 a.m. // 10:00 a.m. // 10:15 a.m. // 10:30 a.m. // 10:45 a.m. // ... // 5:00 p.m. // 5:15 p.m. // 5:30 p.m. // 5:45 p.m. // 6:00 p.m. int main() { int i; int h, m; for(h=9; h<12; h++) // print the morning section first for(m=0; m<60; m+=15) { if(m==0) printf("%2d:00 a.m.\n", h); else printf("%2d:%2d a.m.\n", h, m); } for(h=12; h<13; h++) // handle 12:00pm -- 12:45 separately for(m=0; m<60; m+=15) { if(m==0) printf("%2d:00 p.m.\n", h); else printf("%2d:%2d p.m.\n", h, m); } for(h=1; h<6; h++) // print the afternoon next for(m=0; m<60; m+=15) { if(m==0) printf("%2d:00 p.m.\n", h); else printf("%2d:%2d p.m.\n", h, m); } printf(" 6:00 p.m.\n"); // handle 6:00pm separately as the loops don't work well here for this boundary condition system("pause"); }