I ibexpiotr In Runtime Messages 243 Location New York Jan 27, 2005 #1 C++ can anyone write me a code that converts seconds to hrs and minutes. THX
B bla!! Daemon Poster Messages 1,118 Location /usr/root/mn/us Jan 28, 2005 #2 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
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
OP OP I ibexpiotr In Runtime Messages 243 Location New York Jan 28, 2005 #3 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
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
I Iron_Cross Daemon Poster Messages 549 Location Bamberg, Germany Jan 28, 2005 #4 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 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.
G gab00n In Runtime Messages 287 Jan 28, 2005 #5 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.
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.
I Iron_Cross Daemon Poster Messages 549 Location Bamberg, Germany Jan 29, 2005 #6 My bad Thanks for the correction.