Answer to Question #23766 in C++ for marwan

Question #23766
write a program that prompts the user for an integer value for a length of a youtube clip in seconds then display the number of hours minutes seconds
for example your youtube clip is 7350 seconds length you would display
youtube clip 2 hours 2 minutes and 30 seconds
thank you
1
Expert's answer
2013-02-07T07:50:48-0500
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
cout << "please enter time(sec)" << endl;
& int time;
& cin>>time;
& int h1,hour,m1,minute;
& h1 =time%3600;
& hour=(time-h1)/3600;

& m1 =h1%60;
& minute=(h1-m1)/60;


& cout<<"number hour= "<<hour<<endl;
cout<<"number minute= "<<minute<<endl;
cout<<"number sec= "<<m1<<endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS