Computer Science, asked by shashwasingh, 10 months ago

wap to input time in seconds and split it into hours minutes and seconds​

Answers

Answered by Anonymous
0

Explanation:

Approach:

h hours = h * 60 minutes as 1 hour = 60 minutes.

Similarly h hours = h * 3600 seconds.

Note: To convert m minutes back into hours, do n / 60 and for s seconds s / 3600.

Below is the implementation of the above approach:

// C++ program to convert hours

// into minutes and seconds

#include <bits/stdc++.h>

using namespace std;

// Function to convert hours

// into minutes and seconds

void ConvertHours(int n)

{

long long int minutes, seconds;

minutes = n * 60;

seconds = n * 3600;

cout << "Minutes = " << minutes

<< ", Seconds = " << seconds << endl;

}

// Driver code

int main()

{

int n = 5;

ConvertHours(n);

return 0;

}

Similar questions