Thursday, December 18, 2014

C program to convert time in seconds to hours, minutes & seconds


This C program will convert the time in seconds to hours, minutes and seconds. After running the program, it will ask to provide the time in seconds. Then the time will be converted to hours, minutes and seconds. This program is tested and 100% accurate. Let's try it yourself.
time conversion,converting seconds in hours, minutes and seconds
#include<stdio.h>

main()
{
long sec, minute, hr, t;

printf("Enter time in Seconds: ");
scanf("%ld", &sec);

hr = sec/3600;
t = sec%3600;
minute = t/60;
sec = t%60;

printf("\nTime is %ld hrs %ld mins %ld secs", hr, minute, sec);
}

No comments:

Post a Comment