- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Program for converting hours into minutes and seconds
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
- Related Articles
- Converting seconds into days, hours, minutes and seconds in C++
- Python program to convert seconds into hours, minutes and seconds
- Convert 7290 seconds into hours and minutes.
- Converting seconds in years days hours and minutes in JavaScript
- Add the following:2 hours 13 minutes 40 seconds and 4 hours 23 minutes 35 seconds.
- Subtract 4 hours 20 minutes 36 seconds from 8 hours 18 minutes 20 seconds.
- Convert:3 hours and 12 minutes into hours.
- Hours and minutes from number of seconds using JavaScript
- MySQL DateTime Now()+5 days/hours/minutes/seconds?
- Convert 40 minutes into seconds.
- How to sum time in MySQL by converting into seconds?
- How to convert JavaScript seconds to minutes and seconds?
- How can we create a MySQL function to find out the duration of years, months, days, hours, minutes and seconds?
- What is the ratio between 50 seconds and 10 minutes?
- How to add hours and minutes to a date with JavaScript?

Advertisements