In this post, we will see how to give a time delay in C code. Basic idea is to get current clock and add the required delay to that clock, till current clock is less then required clock run an empty loop.
Here is implementation with a delay function.
This article is contributed by Pratik Chhajer. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to measure time taken by a function in C?
- C program to print digital clock with current time
- Cvent Interview Experience (On campus for Internship and Full Time)
- Measure execution time with high precision in C/C++
- time() function in C
- time.h header file in C with Examples
- time.h localtime() function in C with Examples
- Types of C files after its compilation
- Food Ordering System in C
- Difference between sizeof(int *) and sizeof(int) in C/C++
- Examination Management System in C
- Difference between Static and Dynamic Memory Allocation in C
- How does Volatile qualifier of C works in Computing System
- Header files in C/C++ with Examples
Improved By : ManasChhabra2