Why we are write "return 0" in end of th program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we are write "return 0" in end of th program?

21st May 2018, 3:18 PM
Better call "PD"
Better call "PD" - avatar
2 Answers
+ 22
By standard an integer should be returned to main function to show successful compilation...(the program worked fine...) return is the exit status for main On most OS 0 means success...i.e. 0 is sent to show no error... while other than 0 means error... well it is not compulsory....now just a convention...
21st May 2018, 3:38 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 4
its simple question... getch() getche() printf() clrscr() these all function are created by DR in C and in CPP so who decided it return something or not the simple ans is created decided the function return the value or not.. now back to your question in any language. function is basically created to return something...... so it depends upon us what we want to return which value for it you can return any value like 0,1,......10 any internet number any floating point number or anything you desired but there are some rule... and return command has own limitations you must know this question asked so many time.... you get more and if my ans not satisfied you. you may also search in Q&A Discussion
21st May 2018, 7:51 PM
Arun Tomar
Arun Tomar - avatar