sleep in c programming

The sleep() function is used in C programming to pause the execution of a program for a specified number of seconds. The function is part of the unistd.h library and takes an integer argument representing the number of seconds to sleep.

Here is an example of how to use the sleep() function:

#include <stdio.h>
#include <unistd.h>

int main() {
   printf("Before sleep\n");
   sleep(5); // Pause execution for 5 seconds
   printf("After sleep\n");
   return 0;
}

This program will print "Before sleep", pause for 5 seconds, and then print "After sleep". The sleep() function allows you to introduce delays in your program, which can be useful in various scenarios, such as waiting for user input or controlling the timing of certain operations.