Question

using C++ Write a full program (starting from #include) that takes as input the number of...

using C++

Write a full program (starting from #include) that takes as input the number of seconds after midnight. It then displays the time in hours:minutes:seconds format. Assume the time is displayed in military time, e.g. 06:06:06 or 23:05:57. Note the placement of the zeros for numbers less than 10, which your program should properly display. Your program should show output as in the example below.

Enter number of seconds after midnight: 3601

0 0
Add a comment Improve this question Transcribed image text
Answer #1

here is the complete C++ program as per the requirement.

========================================================

Program:

========================================================

//header files

#include<iostream>

#include<iomanip>

//namespace std;

using namespace std;

//start of the main function

int main()

{

//variables

int seconds, hours, minutes;

cout<<"Enter the number of seconds after midnight: ";

cin >> seconds;

//find minutes

minutes = seconds / 60;

//find hours

hours = minutes / 60;

//display the hours, minutes, seconds

cout << setfill('0')<<setw(2)<<int(hours) << ":" << setfill('0')<<setw(2)<<int(minutes%60)

     << ":" << setfill('0')<<setw(2)<<int(seconds%60)<<endl;

return 0;

}

//end of the main function


========================================================

Sample Output:

=========================================================

Kindly Check and Verify Thanks..!!!

Add a comment
Know the answer?
Add Answer to:
using C++ Write a full program (starting from #include) that takes as input the number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT