20. Make a program that will input seconds, convert it into minutes and hour. Display the equivalent minutes and hour/s . Your program will be terminated if you input zero in the hour.
Ex. Enter seconds: 120
Minutes = 2 (120 seconds/60)
Equivalent Hour is = 0.033 (120 seconds/ 3,600 seconds in 1 hour)
Source code
#include <iostream>
using namespace std;
int main()
{
while(true){
int seconds;
cout<<"\nEnter seconds: ";
cin>>seconds;
double minutes=seconds/60.0;
double hours=seconds/3600.0;
if (hours==0){
break;
}
cout<<"\nMinutes = "<<minutes<<"("<<seconds<<" seconds/60)";
cout<<"\nEquivalent Hour is = "<<hours<<"("<<seconds<<" seconds/ 3,600 seconds in 1 hour)";
}
return 0;
}
Output
Comments
Leave a comment