Connecting Tech Pros Worldwide Help | Site Map

Need Help here?

Newbie
 
Join Date: Dec 2006
Posts: 1
#1: Dec 10 '06
can all of you help me solve my problem... i just dont know where to start on this one?


this is the question?

its a programe that will accept a number of seconds from the user and will display how many hours minutes and seconds it is?

Ex.

if i enter 3600 then the output should be 3600 is equal to 1 hour 0 minutes and 0 seconds?

can u help me about this one? im sory for the disturbance..
Newbie
 
Join Date: Dec 2006
Posts: 4
#2: Dec 10 '06

re: Need Help here?


Have you tried using a cin statement accepting the number of seconds, then using if statements to break it down using greater than and less than symbols?
Member
 
Join Date: Dec 2006
Posts: 38
#3: Dec 10 '06

re: Need Help here?


Quote:

Originally Posted by ting19

can all of you help me solve my problem... i just dont know where to start on this one?


this is the question?

its a programe that will accept a number of seconds from the user and will display how many hours minutes and seconds it is?

Ex.

if i enter 3600 then the output should be 3600 is equal to 1 hour 0 minutes and 0 seconds?

can u help me about this one? im sory for the disturbance..

Expand|Select|Wrap|Line Numbers
  1. int rawSeconds;
  2. cin >> rawSeconds;
  3. int seconds = rawSeconds % 60;
  4. int minutes = (rawSeconds / 60) % 60;
  5. int hours = rawSeconds / 3600;
  6. cout << rawSeconds << "s = " << hours << ":" << minutes << ":" << seconds << endl;
  7.  
Reply