C++ challenges | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++ challenges

int main without return 0 is a valid code ? can I post a screen copy of this cases ?

12th May 2017, 1:49 AM
Anibal Lopes
3 Answers
+ 15
int main() does not require an explicit return 0. If the return value is not given, the compiler automatically understands the return value as 0
12th May 2017, 2:17 AM
Pixie
Pixie - avatar
+ 10
Although it isn't required to explicitly return 0, it's encouraged to. Just saying.
12th May 2017, 6:33 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Normally in functions, if you declare it with a return value, you have to return something that matches that data type. For example: char getRandChar() { //Some code return 'a'; //If this wasn't here, it would give an error. }
12th May 2017, 2:14 AM
Dawzy
Dawzy - avatar