wt s the use of return 0 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

wt s the use of return 0

17th Oct 2016, 1:38 PM
Santhosh Kumar D.S
Santhosh Kumar D.S - avatar
6 Answers
+ 3
Every type function must return a value. If you use void main() you need not use "return 0;" as the last statement of main function. But if the type of main function is other than "void" it must return that type of value, i.e. int main() must return integer value, float main() must return float value, etc. and since 0 can be returned as any data type, we generally use return 0.
17th Oct 2016, 1:59 PM
Sahil Bansal
0
When you create a main function, you specify its return type as an int (void main is not allowed by both the C standard and C++ standard). Technically can return any integer value that you want, but if I recall correctly, some compilers use the 0 return value to signify that the program ran successfully.
18th Oct 2016, 1:43 AM
DaemonErrors
DaemonErrors - avatar
0
it's a good programming practice to indicate to the OS that your program has successfully executed ... if the program is not executed successfully then it will return garbage value
20th Nov 2016, 2:55 PM
Madhu Jayarama
Madhu Jayarama - avatar
- 1
thnks
17th Oct 2016, 2:10 PM
Santhosh Kumar D.S
Santhosh Kumar D.S - avatar
- 1
it means finish
17th Oct 2016, 3:47 PM
saeid242
- 1
thnks
4th Dec 2016, 7:43 AM
utpatti