This is a C++ Program to Convert Hours in Terms of Minutes and Seconds.
The program converts hours into minutes and seconds.
1. The program takes number of hours and stores it.
2. Hours are converted into minutes by multiplying with 60.
3. Seconds are calculated by multiplying minutes with 60.
4. The result is printed.
5. Exit.
Here is the source code of C++ Program to Convert Hours in Terms of Minutes and Seconds. The program output is shown below.
#include<iostream>
using namespace std;
int main ()
{
float hrs, min, sec = 0;
cout << "Enter hours : ";
cin >> hrs;
min = hrs * 60;
sec = min * 60;
cout << "\n" << hrs << " hours = " << min << " minutes = " << sec << " seconds";
return 0;
}
1. The user is asked to enter the number of hours and it is stored in the float variable ‘hrs’.
2. Minutes are calculated by multiplying ‘hrs’ with 60 and the value is stored in ‘min’.
3. ‘min’ is multiplied by 60 and stored in the variable ‘sec’ which gives seconds.
4. Hours in terms of minutes and seconds is then printed.
Case 1 : Enter hours : 6 6 hours = 360 minutes = 21600 seconds Case 2 : Enter hours : 1.5 1.5 hours = 90 minutes = 5400 seconds Case 3 : Enter hours : 24 24 hours = 1440 minutes = 86400 seconds
Sanfoundry Global Education & Learning Series – C++ Programs.
To practice all C++ programs, here is complete set of 1000+ C++ Programming examples.
- Check Computer Science Books
- Apply for C++ Internship
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check C++ Books