Question: Please see this:

```
int f();
int g();

int main()
{
   f(); 
   g(); 

   return 0;
}

int f()
{
   // In case of fail
   return 1;
}

int g()
{
   return 0;
}

```

So in case i have an `error` in `f()` how can i immediately exit from `main` without run `g()` and return `0` from `main`. 

What is the right way to do that ?

Answer: 
You can exit from the application like below:

```
int main()
{
  if (f())//if statement does not require `}` if it has only one statement. Here it is only `exit(1)` statement.
    exit(1);// error exit, you can use return 1; as well. Because here f() returns 1
  g();
  exit(0);  // correct execution exit. You can use return 0; as well.
}

```

Now you can check the exit status like below:-

UNIX/LINUX
`echo $?`

WINDOWS
`echo %ERRORLEVEL%`
```
int f();
int g();

int main()
{
  int value;
   if(!f()){

 return 0;
 }else{
 value= g();
    } 

 return value;
 }

int f()
 {

   if(stat=='correct'){
    // In case of success
   return 1;
  }
   else{ // In case of fail
    return 0;}
  } 

  int g()
 {
    if(stat=='correct'){
    // In case of success
   return 1;
  }
    else{ // In case of fail
    return 0;}
  }

```