KodeGod.com

020. Technical interview question: Convert time in seconds to hours

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