English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Input is in hours, the task is to convert the number of hours to minutes and seconds, and display the corresponding result
The formula used to convert hours to minutes and seconds is-
1 hour = 60 minutes Minutes = hours * 60 1 hour = 3600 seconds Seconds = hours * 3600
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
The following program uses the following methods-
Enter the number of hours in an integer variable, assume n
Apply the given conversion formula to convert hours to minutes and seconds
Display Result
START Step 1-> declare function to convert hours to 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
#include <bits/stdc++.h> using namespace std; //Convert hours to 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 Result
3 hours in minutes are 180 3 hours in seconds are 10800