Program to Convert Time in Seconds to Hours

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

#include <stdio.h>

#include< conio.h>

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);

getch();

}

 

Mohit Arora
Follow me