+ 1

why don't we use void instead of int as a return type for main function?

29th Sep 2016, 3:11 PM
siddharth jadhav
siddharth jadhav - avatar
2 Answers
+ 2
When you write a program , compile it and then run it, it becomes a process. Every process has a return value. While the process is running , one program(operating system) calls another program , so returning some value to the calling program is considered success and also as an exit status. But in void , since we don't return anything and we can't ascertain the exit status of the program , it is usually avoided in most of the compilers .
29th Sep 2016, 6:51 PM
Divya M R
Divya M R - avatar
0
what if we use void return type... will it cause any problem??
3rd Oct 2016, 2:25 PM
Saptarshi Saha
Saptarshi Saha - avatar