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
// 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
#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.