Write a program that asks the user to enter a number of seconds.

Write a program that asks the user to enter a number of seconds. 

  There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. 

 There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds. 

 There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds

code :

#include<iostream>

using namespace std;

int main() {

double sec, Minute, Houre, Day;

cout << "Enter value in seconds:";

cin >> sec;

if (sec >= 60 && sec < 3600) {

Minute = sec / 60;

cout << "you enter " << Minute << " min" << endl;//one minute = 60

}

else if (sec >= 3600 && sec < 86400) {

Houre = sec / 3600;

cout << "you enter " << Houre << " Houre" << endl;//one Houre = 3600

}

else if (sec >= 86400 ) {

Day = sec / 86400;

cout << "you enter " << Day << "  Day" << endl;//one Day = 86400

}

system("pause");

return 0;

}

output :

Enter value in seconds:60

you enter 1 min

Post a Comment

0 Comments