***************************** C++ program ***************************** Write a
ID: 3668710 • Letter: #
Question
*****************************
C++ program
*****************************
Write a program to simulate a clock.
Your program should run for approximately 10 seconds.
Use the following main() for your program.
Your printTimeNow() function must make use of the tm struct.
int main()
{
for (int i = 0; i < 10; i++)
{
system("cls"); // Use cls on Windows or clear on Linux to clear the screen
printTimeNow();
delay();
}
}
If you are using Xcode for this exercise, you might want to use another compiler, so you can effectively clear the screen.
Use this delay() function to simulate a delay of one second
void delay()
{
for (int i = 0; i < 600000000; i++); // Vary the size of this loop to approximate one second
}
******************************************************
Your output should look like this, displaying the current time, and changing every second as the program runs.
Explanation / Answer
Put your name, the compiler used, and Lab Exercise #11 in a comment at the top of your program. Email your source code. This lab exercise is due at the beginning of the next lecture. You may email your lab solution prior to that.
Write a program to simulate a clock. Your program should run for approximately 10 seconds. Use the following main() for your program. Your printTimeNow() function must make use of the tm struct.
int main()
{
for (int i = 0; i < 10; i++)
{
system("cls"); // Use cls on Windows or clear on Linux to clear the screen
printTimeNow();
delay();
}
}
If you are using Xcode for this exercise, you might want to use another compiler, so you can effectively clear the screen.
Use this delay() function to simulate a delay of one second
void delay()
{
for (int i = 0; i < 600000000; i++); // Vary the size of this loop to approximate one second
}
Your output should look like this, displaying the current time, and changing every second as the program runs.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.