how do i convert time from seconds to HH:MM:SS in c++?
I'm can only use these libraries
#include%26lt;iostream%26gt;
#include%26lt;string%26gt;
#include%26lt;iomanip%26gt;
#include%26lt;cmath%26gt;
how would you calculate it mathematically? and how should i implement it in C++?
C++ : convert time from seconds to Hours, Mins and Seconds?
void main()
{
int time,hour,min,sec;
cout%26lt;%26lt;"Enter time in seconds :";
cin%26gt;%26gt;time;
hour=time/3600;
time=time%3600;
min=time/60;
time=time%60;
sec=time;
cout%26lt;%26lt;"\n\nThe time is : "%26lt;%26lt;hour%26lt;%26lt;"::"%26lt;%26lt;min%26lt;%26lt;"::"%26lt;%26lt;sec;
}
for this program, you just need iostream.h
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment