Tuesday 10 July 2012

Program for Conversion of Time from 24 hr clock to 12hr clock


#include<stdio.h>
#include<conio.h>
/* conversion of time from 24 hr clock to 12hr clock*/
void main()
{
int min, time, sub, hour;


clrscr();


printf("enter the time in 24 hour notation");
scanf("%d",&time);


min=time%100;
sub=time-min;
hour=sub/100;

if(hour>12)
{
hour=hour-12;
printf("%d",hour);
printf("|%dpm",min);
}

else if(hour<=12)
{
if(hour==0)
{
hour=hour+12;
}
printf("%d",hour);
printf("|%dam",min);

}


getch();


}

No comments:

Post a Comment