![]() |
VOOZH | about |
The Return statement in C/C++:
There are two scenarios in which return statements will be used:
:
Important characteristics of the return statement:
Below is a program to illustrate the use of return 0 and return 1 inside the main function:
Division by zero is not possible.
Time Complexity: O(1)
Auxiliary Space: O(1)
:
Below is a program to illustrate the use of return 0 and return 1 inside the user-defined function:
You are an adult
Time Complexity: O(1)
Auxiliary Space: O(1)
Conclusion:
| Use-case | return 0 | return 1 |
| In the main function | return 0 in the main function means that the program executed successfully. | return 1 in the main function means that the program does not execute successfully and there is some error. |
| In user-defined function | return 0 means that the user-defined function is returning false. | return 1 means that the user-defined function is returning true. |