Write a cpp program that asks the user to enter the time in terms of seconds. Th
ID: 3882856 • Letter: W
Question
Write a cpp program that asks the user to enter the time in terms of seconds. Then the program prints the time in the format of h: m: s 1 hour = 60 minutes or 3600 seconds minute= 60 seconds You need to use modules operator in your code Your output format should be "xxx Requirement: code seconds equal to h: m: s", where xxx is the seconds you inputted and h, m, s are the whole hours, minutes, seconds in the xxx seconds. For example, if the user enters 3601, the program prints "3601 seconds equal to 1: 0: 1", which means 1 hour: zero minute: 1 second.Explanation / Answer
#include<iostream>
using namespace std;
int main(){
long int n;
cout<<"Enter seconds ";
cin>>n;
int hr = n/3600;
int k=n%3600;
int min = k/60;
int sec = k%60;
cout<<"hr:mn:se"<<endl;
cout<<hr<<":"<<min<<":"<<sec;
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.