Why do we have to write int with main() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do we have to write int with main()

15th Jan 2017, 5:30 AM
nishika
4 Answers
+ 7
Because main() is a function which returns an integer value to the operating system.
15th Jan 2017, 6:11 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
The system only calls the main function and nothing else. Further calls are your responsibility. If your main doesn't exist it will give an error of not finding entry point, if it's blank well - it will do what it's told to - nothing.
15th Jan 2017, 7:59 AM
Norbivar
Norbivar - avatar
0
What will happen if I don't write codes in main() but in another function such as"test()", and I don't have any other functions?
15th Jan 2017, 7:40 AM
Réveil
0
Got it.Thanks
15th Jan 2017, 8:01 AM
Réveil