Why main function must return integer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why main function must return integer?

19th Jun 2017, 12:50 PM
Muhammad Fauzan Azmi Arzaki
Muhammad Fauzan Azmi Arzaki - avatar
3 Answers
+ 11
So that it indicates to the main function that the code ran without any error. Generally​ return 0 is used. https://www.sololearn.com/Discuss/220394/?ref=app
19th Jun 2017, 1:22 PM
Frost
Frost - avatar
0
It's because you're probably using "int main()". You need to return a value if you're using int. If you use "void main()" you actually don't need to return anything at all! Hope it helps :D
20th Jun 2017, 1:34 AM
Aoife
Aoife - avatar
0
it cause errors if i use "void main()", even if if i use "long int main()"
20th Jun 2017, 2:42 PM
Muhammad Fauzan Azmi Arzaki
Muhammad Fauzan Azmi Arzaki - avatar