I was writing a c++ program that converts time into: hours, minutes, and seconds.
What I need to do is to convert time into the form of: HH:MM:SS, anyways
here is my code:
#include <iostream>
using namespace std;
int main() {
long time, hour, min, sec;
cout<<"Enter elapsed time: ";
cin>>time;
cout<<time;
hour = time/3600;
min = (time%3600) / 60;
sec = (time%3600) % 60;
cout<<"\nIn HH:MM:SS -> ";
cout<<hour<<":"<<min<<":"<<sec;
return 0;
}
When I enter time in example: 3600, it displays 1:0:0 unlike the form I'm looking forward, so I need it to be displayed as "01:00:00" in this form. What should I do?