Akshaya ADAPA
last year
Akshayacountry asked

What will happen if we don't use "return" while programming?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

In C programming, when we write a function like int main(), it’s common to end it with a return statement.

Without using return inside the main() function, the program won't necessarily break immediately — it might still work, especially with modern compilers that assume a zero return value for the main() function.

Returning 0 usually indicates that a program executed successfully.

However, explicitly writing return 0; as you end your main() function is considered good practice.

When your program ends successfully, this zero value signals to the operating system that everything went smoothly.

Overall, although it may seem like a small detail, including return 0; helps ensure that your code adheres to standard practices and communicates effectively with the operating system.

C
This question was asked as part of the Learn C Programming course.