int main or void main..? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

int main or void main..?

Can either of these be used ..? I tried but why doesn't void main work on Sololearn

16th Jul 2020, 8:45 AM
Onyx
Onyx - avatar
3 Answers
+ 3
No need to select 'void main()'. Because, main function should return some return value in order to verify that our code was compiled well by compiling platform. If main() does't return anything, that compiling platform won't give any guarantee that program was compiled perfectly.
16th Jul 2020, 8:53 AM
Crazy_programmer
Crazy_programmer - avatar
+ 5
In modern compiler from the new c++ standards, if required main return type should be int. But in old compilers it was void. Edit: This may help for clarity.... https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c
16th Jul 2020, 8:49 AM
Jayakrishna 🇮🇳
0
Void : non returnable datatype, your need to print the outcome. Int:-returnable datatype ,it will return outcome as such.
16th Jul 2020, 6:36 PM
shubham kumar
shubham kumar - avatar