Skip to main content

Posts

Showing posts with the label Exit()

Exit( ) function in C programming

We have already known that we can jump out of a loop using either the break statement or goto statement. In a similar way, we can jump out of a program by using the library function exit( ). In case, due to some reason, we wish to break out of a program and return to the operating system. The general syntax is - - - - - - - - - - if (condition) exit (0) ; - - - - - - - - - - The exit( ) function takes an integer value as its argument. Normally zero is used to indicate normal termination and non zero value to indicate termination due to some error or abnormal condition. The use of exit( ) function requires the inclusion of the header file <stdio.h>. /* Program to demonstrate exit( ) */ #include<stdio.h> #include<stdlib.h> main() { int choice ; while(1) { printf (“ 1. Create database\n”) ; printf (“ 2. Insert new record\n”) ; printf (“ 3. Modify a record\n”) ; printf (“ 4. Delete a record\n”) ; printf (“ 5. Display all records...