The Program in C++ to Find Total number of minutes between two given times is given below:
#include <iostream>
using namespace std;
int main() {
int start_hour, start_minute, end_hour, end_minute;
cout<<"Hello Codeauri Family, Enter the start hour and start minute here:\n";
cin>>start_hour>>start_minute;
cout<<"Hello Codeauri Family, Enter the end hour and end minutes here:\n";
cin>>end_hour>>end_minute;
int start_total_minutes = start_hour * 60 + start_minute;
int end_total_minutes = end_hour * 60 + end_minute;
int total_minutes = end_total_minutes - start_total_minutes;
cout << "Total minutes between the two times: " << total_minutes << endl;
return 0;
}
Output:
Hello Codeauri Family, Enter the start hour and start minute here:
10 20
Hello Codeauri Family, Enter the end hour and end minutes here:
12 20
Total minutes between the two times: 120
Pro-Tips💡
This program prompts the user to enter the starting and ending times in hours and minutes.
Then it converts the hours to minutes and find the total minutes.
Then it calculates the difference between the total minutes of end time and start time to find the total minutes between two given times.
The result is then printed to the console.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.