+ 2

why we return value 0 Not other value like 1,2etc.

please answer

26th Sep 2016, 1:45 PM
rahul negi
rahul negi - avatar
4 Answers
+ 6
Technically, in C or C++ main function has to return a value because it is declared as "int main" which means "main function should return integer data type" if main is declared like "void main", then there's no need of return 0. Some compilers even accept and compile the code even if u dont write return 0. varies from compiler to compiler if you write void main (), then we don't return anything. and if it's int main () , then you can return any value like 1,2,0 etc.
26th Sep 2016, 2:06 PM
MAZHAR IMAM KHAN
MAZHAR IMAM KHAN - avatar
+ 2
You can use other values.
26th Sep 2016, 1:55 PM
Piotr
Piotr - avatar
+ 1
why we can't leave it empty returned only
26th Sep 2016, 2:04 PM
rahul negi
rahul negi - avatar
+ 1
return statement can be empty I.e. return; if return type of the function is void in nature
26th Sep 2016, 3:54 PM
Supriya P