+ 2

Is it necessary to use return 0 in c++ programs?

18th Mar 2017, 5:07 PM
Shiva
Shiva - avatar
3 Answers
+ 31
return 0 indicates to your main() that your program has run successfully without any errors. You can use void main() if you don't want to write return 0 Also for int main() if you don't write return 0 it is understood by the compiler by default.
18th Mar 2017, 5:21 PM
Frost
Frost - avatar
+ 2
Better use int main() and return 0 if your program exits normally. void main() does not conform to standard and compilers will give you warnings about this.
19th Mar 2017, 8:31 AM
hdo
hdo - avatar
+ 1
no it's not necessary if u use void main in place of int main
14th Apr 2017, 3:30 AM
Sumit Shaurabh
Sumit Shaurabh - avatar