+ 4

What's the difference between void main() and int main()?

23rd Nov 2016, 4:26 PM
Jaydeep Khatri
Jaydeep Khatri - avatar
5 Respostas
+ 5
When we return 0 at the end ( while using int as the return type) it tells the OS that the program is functional and is without any error(except logical error), as main function is called by OS and it returns 0 to the OS. In C++, there is no difference, both are same.
23rd Nov 2016, 5:26 PM
PRIYA🙌
+ 1
When ur function returning a value... U have to use int main() & when not then use void main()..!!! They show the return type of a function..
23rd Nov 2016, 5:53 PM
rohit bisht
rohit bisht - avatar
0
If it's void, explicitly return value is not mandatory. But in case of int main() it demands a return value. Basically, it's your choice how you want your main() to act. I'm not very sure if I'm correct.
23rd Nov 2016, 4:33 PM
Swapna Priya Valluri
Swapna Priya Valluri - avatar
0
void does not return anything but int does
23rd Nov 2016, 4:40 PM
Nikolaj Agger
Nikolaj Agger - avatar
0
void as the name suggests , basically means that your programme need not return any value while int main means the program after compilation must return a value and of type integer
23rd Nov 2016, 4:50 PM
Learner
Learner - avatar