While loop checks the input condition first and exits if the condition fails. Do-while loop enters the loop for the first time by default and executes the statements inside the loop before checking the condition. This nature of do-while loop is essential for making a menu driven program where we need to show a list of options to the user and wait for the user’s input. The following example shows a menu driven program using do-while loop.
int main(int argc, char *argv[]) { do { printf("Add an user [a]\n"); printf("Delete an user [d]\n"); printf("View user's record [v]\n"); printf("Modify user's record [m]\n"); printf("Press ESC to exit\n:"); key = getch(); }while(key != 27); }
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Most popular
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average