Write the entire code for the following The purpose of this assignment is to learn use of the

Write the entire code for the following: The purpose of this assignment is to learn use of the simplest type of functions.Problem Statement#include Using namespace std;int main(){cout <<"------n" <<"| |n" <<"------n";cout <</t "------n" <</t"| |n" <</t" ------n";cout <</t/t"------n" <</t/t"| |n" <</t/t"------n";return 0;}The objective of this assignment is to modify the above program such that it uses different functions to show each different panel and the structure of the program should look like the one shown in Fig. 2. The execution result of the modified program should be identical to that of the previous version.What to doMake copy of the previous program (note: if you have improved that program since then, you should copy the improved version).In the previous program t you wrote a program using a single function main(), whose structure looked like that shown in Fig. 1 at the end of the assignment, to display a multi-panel comic strip.Modify the program so that it uses a different function to show each different panel and the structure of the program should look like that shown in Fig. 2 at the end of the assignment.On Linux, the sleep() function from the unistd.h library can be used to cause the program to pause for a specified number of seconds.For example, if one calls sleep(1), the program will pause for 1 second.Modify the definition of each panel-display function so that it pauses the program for 1 second after displaying the designated panel.Compile and run the program.Update the documentation part accordingly and re-compile/execute the program to ensure that you did not accidentally change any other part of the program.Correct any mistakes before proceeding to the next assignment.HintsTo use the sleep() function, you need to include the following line at the top of your program: #include Here is an example of how to use the sleep() function in a panel-display function:void display_panel_1() { // code to display panel 1 sleep(1); } Note: The use of the sleep() function will cause the program to pause for 1 second after displaying each panel. This will give the user time to see each panel before moving on to the next one.To clear the screen between each panel, you can use the system("clear") function. system("clear"); Simple FunctionsFunctions are blocks of code that can be called repeatedly from different parts of your program. Functions can make your code more organized and reusable.Here's a simple example of a function that prints out text and then waits for one second:#include #include void printMessage() { cout << "Hello, I'm a function!" << endl; sleep(1); } int main() { printMessage(); return 0; } When you run this program, the output will be:Hello, I'm a function! In this example, the printMessage function is defined using the void keyword, which indicates that the function does not return any value. The function contains a cout statement that prints out the message "Hello, I'm a function!" and a sleep function call that pauses the program for one second. The main function is the entry point of the program, and it calls the printMessage function. sleep()The sleep function can be used to cause a program to pause for a specified number of seconds. This can be useful when you want to display information to a user and give them time to read it before continuing on to the next piece of information.On Linux, the sleep function is part of the unistd.h library, which is a standard library for Unix-based systems. To use sleep in a C++ program on Linux, you need to include the following line at the top of your program:#include The sleep function takes a single argument, which is the number of seconds that the program should pause for. For example, the following code will cause the program to pause for 1 second:sleep(1); Example#include #include using namespace std; int main() { cout << "Starting program...n"; cout << "Pausing for 2 seconds...n"; // The sleep function is used to pause the program for a specified number of seconds. // In this case, we are using the sleep function from the unistd.h library to pause the program for 2 seconds. sleep(2); cout << "Program resumed.n"; cout << "Exiting...n"; return 0; } The output of the program will be:Starting program... Pausing for 2 seconds... Program resumed. Exiting... This program demonstrates how to use the sleep function from the unistd.h library to pause the program for a specified number of seconds. In this example, the program outputs some text to the console, pauses for 2 seconds using the sleep function, and then outputs some more text to the console before exiting.

Write the entire code for the following: The purpose of this assignment is to learn use of the simplest type of functions.Problem Statement#include Using namespace std;int main(){cout <<"------\n" <<"| |\n" <<"------\n";cout <Here is an example of how to use the sleep() function in a panel-display function:void display_panel_1() {
// code to display panel 1
sleep(1);
} Note: The use of the sleep() function will cause the program to pause for 1 second after displaying each panel. This will give the user time to see each panel before moving on to the next one.To clear the screen between each panel, you can use the system(“clear”) function. system(“clear”); Simple FunctionsFunctions are blocks of code that can be called repeatedly from different parts of your program. Functions can make your code more organized and reusable.Here’s a simple example of a function that prints out text and then waits for one second:#include
#include

void printMessage() {
cout << "Hello, I'm a function!" << endl; sleep(1); } int main() { printMessage(); return 0; } When you run this program, the output will be:Hello, I'm a function! In this example, the printMessage function is defined using the void keyword, which indicates that the function does not return any value. The function contains a cout statement that prints out the message "Hello, I'm a function!" and a sleep function call that pauses the program for one second. The main function is the entry point of the program, and it calls the printMessage function. sleep()The sleep function can be used to cause a program to pause for a specified number of seconds. This can be useful when you want to display information to a user and give them time to read it before continuing on to the next piece of information.On Linux, the sleep function is part of the unistd.h library, which is a standard library for Unix-based systems. To use sleep in a C++ program on Linux, you need to include the following line at the top of your program:#include The sleep function takes a single argument, which is the number of seconds that the program should pause for. For example, the following code will cause the program to pause for 1 second:sleep(1); Example#include
#include
using namespace std;

int main() {
cout << "Starting program...\n"; cout << "Pausing for 2 seconds...\n"; // The sleep function is used to pause the program for a specified number of seconds. // In this case, we are using the sleep function from the unistd.h library to pause the program for 2 seconds. sleep(2); cout << "Program resumed.\n"; cout << "Exiting...\n"; return 0; } The output of the program will be:Starting program... Pausing for 2 seconds... Program resumed. Exiting... This program demonstrates how to use the sleep function from the unistd.h library to pause the program for a specified number of seconds. In this example, the program outputs some text to the console, pauses for 2 seconds using the sleep function, and then outputs some more text to the console before exiting.


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (2 ratings) 2 out of 2 people found this solution helpful.