You are here:

C/C Language

Advertisement


Question
Can you please give a scenario where exit(0) is used and where exit(1) is used.

Answer
exit(0) is denote the successful completion of function or method.
and exit(1) denote the un-successful completion or abnormal termination of method or function.

Example of exit(0) and exit(1) is as

#include <stdio.h>
#include <stdlib.h>
void main()
{
 int status = 0;
printf("enter status value either o for normal termination or 1 for abnormal");
scanf("%d",&status);
 if (status== 1)
   exit(1);
 else
   exit(0);
/* this line never gets to execute because of the program is either normal termination or abnormal termination according to status value.
*/
 status = 1;
}


C

All Answers


Answers by Expert:


Ask Experts

Volunteer


bharat kumar dhaker

Expertise

programming question in c.

Experience

programming since 2008 from my college day's.

Education/Credentials
b.tech in computer science.

©2016 About.com. All rights reserved.