# C++ Program for converting hours into minutes and seconds

C++Server Side ProgrammingProgramming

Given with the input as hours and the task is to convert the number of hours into minutes and seconds and display the corresponding result

Formula used for converting the hours into minutes and seconds is

1 hour = 60 minutes
Minutes = hours * 60
1 hour = 3600 seconds
Seconds = hours * 3600

## Example

Input-: hours = 3
Output-: 3 hours in minutes are 180
3 hours in seconds are 10800
Input-: hours = 5
Output-: 5 hours in minutes are 300
5 hours in seconds are 18000

Approach used in the below program is as follows

• Input the number of hours in an integer variable let’s say n
• Apply the formula of conversion given above to convert hours into minutes and seconds
• Display the result

## Algorithm

START
Step 1-> declare function to convert hours into minutes and seconds
void convert(int hours)
declare long long int minutes, seconds
set minutes = hours * 60
set seconds = hours * 3600
print minute and seconds
step 2-> In main()
declare variable as int hours = 3
Call convert(hours)
STOP

## Example

#include <bits/stdc++.h>
using namespace std;
//convert hours into minutes and seconds
void convert(int hours) {
long long int minutes, seconds;
minutes = hours * 60;
seconds = hours * 3600;
cout<<hours<<" hours in minutes are "<<minutes<<endl<<hours<<" hours in seconds are "<<seconds;
}
int main() {
int hours = 3;
convert(hours);
return 0;
}

## Output

3 hours in minutes are 180
3 hours in seconds are 10800
Published on 20-Nov-2019 17:41:09