Why does the hello world program works even after replacing return 0 with return 2 or return 5? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does the hello world program works even after replacing return 0 with return 2 or return 5?

#include <stdio.h> int main() { printf("Hello, World!\n"); return 2; } #include <stdio.h> int main() { printf("Hello, World!\n"); return 5; }

23rd Jun 2019, 3:20 AM
Kushaal Kumar Pothula
Kushaal Kumar Pothula - avatar
1 Answer
+ 1
Some operating systems check the return value and will behave differently based on it. Normally, it is used in scripts or programs to do extra error processing after your code completes.
23rd Jun 2019, 11:21 PM
John Wells
John Wells - avatar