What's the difference between 'main ()' and 'void main ()' and how does it affect the program in C? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What's the difference between 'main ()' and 'void main ()' and how does it affect the program in C?

3rd Feb 2018, 7:41 PM
Aditya
Aditya - avatar
2 Answers
+ 3
The default return type of a function in C is int so main() is int main() which returns an integer value and void main just doesnt return anything. It can be usefull when you are recursing through main().
3rd Feb 2018, 7:47 PM
Saminjay Goel
Saminjay Goel - avatar
0
if there is no return type mentioned with main() than default is int.
3rd Feb 2018, 7:46 PM
Bhavya Sharma
Bhavya Sharma - avatar