doubt in basics in c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

doubt in basics in c

the purpose using return 0?

11th Sep 2020, 3:15 PM
Monica
Monica - avatar
2 Answers
+ 7
Return 0 means the end of the executayion of a programme. It is used at the end of the programme to stop executing it
11th Sep 2020, 3:18 PM
Sadman Sakib
Sadman Sakib - avatar
+ 4
return from main() is equivalent to exit the program terminates immediately execution with exit status set as the value passed to return or exit return in an inner function (not main) will terminate immediately the execution of the specific function returning the given result to the calling function. exit from anywhere on your code will terminate program execution immediately. status 0 means the program succeeded. status different from 0 means the program exited due to error or anomaly. in main function return 0 or exit(0) are same but if you write exit(0) in different function then you program will exit from that position. returning different values like return 1 or return -1 means that program is returning error . When exit(0) is used to exit from program, destructors for locally scoped non-static objects are not called. But destructors are called if return 0 is used.
11th Sep 2020, 3:59 PM
A S Raghuvanshi
A S Raghuvanshi - avatar