Write a method that receives elapsed time in seconds as a parameter.The method should then display the elapsed time in hours , minutes and seconds.For example , If the elapsed time is 9630 seconds , then the method should display 2:40:30 . Write a main() method that will prompt a user for elapsed time of an event in seconds, And use received value to demonstrate that the method works correctly.
#include <iostream>
using namespace std;
void Convert(int secs){
int hr = 0;
int mn = 0;
int sec = 0;
hr = secs/3600;
secs = secs%3600;
mn = secs/60;
secs = secs%60;
sec = secs;
cout<<hr<<" : "<<mn<<" : "<<sec<<"\n";
}
//Testing code
int main(){
Convert(9630);
}
Comments
Leave a comment