Program to Convert Time in Seconds to Hours, Minutes and Seconds

This program asks the user to enter the times in term of seconds. Then it convert time in seconds to hours, Minutes and seconds.



Void main()


long sec, hr, min, t; // Declaration of variables

printf(“\n Enter time in seconds: “);

scanf(“%ld”, &sec);  // we have used ld for long integer

hr = sec/3600;

t = sec%3600;

min = t/60;

sec = t%60;

printf(“\n\nTime is %ld hrs %ld mins %ld secs”, hr, min, sec);



Mohit Arora
Follow me