# C Program to convert Seconds into Hours, Minutes and Seconds POSTED BY Mohd ShibliCATEGORY C-programming The Logic

We have two cases here:1) When the number of minutes is greater than 60.2) When the number of minutes is lesser than 60.
When the number of minutes will be greater than 60, then we will have to include the hours; else, it is unnecessary.The formulae that we will be using to split the seconds into equivalent minutes and seconds for case 1 is… If user enters 2300, then2300/60 = 38 … (minutes)2300\%60 = 20 … (seconds)Here, 38 is the number of minutes and 20 is the number of seconds.Thus, 2300 secs = 38 mins and 20 secs.
For case 2, lets take an example where user enters integer seconds more than 3600 (3600 seconds = 1 hour).If user enters 4567, using the above formulae,4657/60 = 77 … (minutes)4567\%60 = 37 … (seconds)The formulae that we will be using to split the minutes into equivalent hours and minutes for case 2 is… 77/60 = 1 … (hours)
77\%60 = 17 … (minutes)Thus, 4567 secs = 1 hour 17 mins 37 secs.Now, we have the logic in our mind. Time for Coding!
Program:-

This ends your program.Output of the above code will be as shown below for both the conditions. 