// Simulate a clock
#include
<iostream>
#include
<iomanip>
using namespace std;
void delay1Second(); // prototype
int main()
{
unsigned short hr, min, sec, duration;
cout << "How many seconds do you want to run your clock?
";
cin >> duration;
cout << "Enter hours minutes seconds => ";
cin >> hr >> min >> sec;
for (int i = 0; i < duration; i++)
{
delay1Second();
++sec;
min += sec/60;
hr += min/60;
sec %= 60;
min %= 60;
hr %= 24;
cout << setfill('0');
cout << setw(2) << hr << ':'
<< setw(2) << min << ':'
<< setw(2) << sec << endl;
}
return 0;
}
void delay1Second()
{
for (int i = 0; i < 400000000; i++) ;
}