Ad

Chapter - 4: The Loop Control Structure

Write a program to print 24 hours of the day with suitable suffixes like AM, PM, Noon and Midnight.


Ad
E
Sections
16
Exercises
#include<stdio.h>
#include<conio.h>
int main()
{
	int hr;
	for(hr = 0; hr < 24; hr++)
	{
		if(hr == 0)
			printf("\n12 Midnight");
		if(hr > 0 && hr < 12)
			printf("\n%d AM", hr);
		if(hr == 12)
			printf("\n%d Noon.", hr);
		if(hr > 12 && hr < 24)
			printf("\n%d PM.", hr-12);
	}
	getch();
	return 0;
}
Ad

© 2024 Garbage Valuegarbage value logo