What is the difference between int main() & Void main() ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the difference between int main() & Void main() ?

12th Jan 2018, 4:41 PM
Satyam Kumar Singh
Satyam Kumar Singh - avatar
7 Answers
12th Jan 2018, 5:30 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
void return type for main should never be used. As simple as that. http://www.stroustrup.com/bs_faq2.html#void-main
13th Jan 2018, 1:19 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
Actually in c++ only int main is used, remember we write return 0; to tell that code is ended properly, so main() function returns integer so int main is used. void main() is invalid in c++. But in c void main can also be used but it is not considered as a good practice, but it is okay to use void if your main() may not return any value.
12th Jan 2018, 4:54 PM
Lakshay
Lakshay - avatar
+ 6
@Hatsy Rei, by now you must have helped, 5 thousand 6 hundred plus people with ur posts, it's time now to make a support bot for SoloLearn posts 😁😁, btw how to proceed if we wanna mk something like that , assuming we have a supportive API from SL
13th Jan 2018, 1:49 AM
Morpheus
Morpheus - avatar
+ 2
If you wright int main , your program return value to operation system. void main - does not return value.
12th Jan 2018, 5:21 PM
Ivan Olegovich
Ivan Olegovich - avatar
+ 2
write void main and write return 0 error occur now think yourself
13th Jan 2018, 8:20 AM
Arun
+ 1
means void is not necessary
13th Jan 2018, 5:10 PM
ratnaprabha purandare
ratnaprabha purandare - avatar