What is the difference between return 0 and return 1?

In some programs we see return 0 while in others return 1 is used.What is the difference between the two?

  • Nisha
  • 28 Jan
  • 21129 Views
  • 5 Answers
Your Answer

Returning 0 or 1 from main() function can be different from the return of a developer defined functions.

The value returned from main() is returned to the shell that called the program. This shell interprets :

0 as a "no error" case,
values greater than 0 indicate some error;
and the actual value returned might contain some custom research paper information on what kind of error has occurred.

Returning 0 or 1 (or any non-zero number) from a developer defined functions can have any meaning what the developer wants.

Generally, the return values convert to the boolean values ‘false’ for 0 and ‘true’ for non-0 values in a context where a conversion to boolean happens, for example, if your function call is within an ‘if’ condition, `if(myFunction())…`, here if myFunction() returns 0, the statements inside the if won’t get executed.

0
c programming
Practice Mock Test
c programming