convert seconds to hrs and mins

Status
Not open for further replies.
Reeks of someone not wanting to do their homework.

Think about the basics.

Take input from the user
Do a quick calcuation (X/3600) to convert to hours or (x/60) to convert to minutes
Print out the new value
 
u dont understand..
heres an expample. u got 7300seconds(2hrs and 10mins- if im not mistaken)

and the output should look like this . 2rhs and 10mins. i know that i need to extract the remainder somehow,,

pls help
 
you use the modulo operator %.
Convert it to minutes first, then use the modulo operator to convert to hours and minutes:
Code:
int seconds = 7300;
int minutes = 0;
int hours = 0;

// start calculation
minutes = seconds/60;
hours = minutes/60;
minutes = minutes%60;
I'm getting 2hr 1min btw. Then you just use a printf() to print the values.
 
You forgot the s, it is modulos operator. It is just simple maths, just play around next time to figure it out by yourself. Yuo won't learn anything if eveybody else has to solve it for you.
 
Status
Not open for further replies.
Back
Top Bottom