Why dont we used return 2; instead of return 0; ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why dont we used return 2; instead of return 0; ??

hey help me plz

16th Nov 2016, 5:48 PM
Maham Maham
Maham Maham - avatar
5 Answers
+ 4
you can use return 2 too or return any int or int variable if main is int declared return tells the program which variable to return inside function main is also a function and follows these
16th Nov 2016, 8:12 PM
Sandeep Chatterjee
+ 3
You can return any value you like, it's still going to bring the program to an end. However, zero is prefered because it is a C++ standard that the return value of zero indicates that the program has run successfuly without any issues. Another return value (usually 1), indicates that there was a problem with the program, and did not end as expected. These non-zero return codes can help diagnose issues if we were to run our program from an external source.
16th Nov 2016, 9:24 PM
Cohen Creber
Cohen Creber - avatar
+ 2
u can.. but return type must be int we write return 0 coz of int main().. int main() must return some integer that's y we use return 0
16th Nov 2016, 5:52 PM
Vishal Mahato
Vishal Mahato - avatar
+ 1
I'm good
17th Nov 2016, 11:21 AM
Mohammed Osama
Mohammed Osama - avatar
0
thank u soo much all of you It helped me
18th Nov 2016, 3:01 PM
Maham Maham
Maham Maham - avatar