0

why is it necessary to write return 0 then }

10th Jul 2016, 9:29 AM
Saptarshi Saha
Saptarshi Saha - avatar
5 Respostas
+ 2
return o will terminate the program as soon as it is encountered with int main. return 0 used to return a value to the user , to avoid using it void main can be used as a replacement to int main
10th Jul 2016, 11:13 AM
utkarsh
+ 1
At the time of declaring main is it necessary to return any value or not.lf we use void before main not necessary
10th Jul 2016, 9:45 AM
Y.Niranjan Reddy
Y.Niranjan Reddy - avatar
+ 1
return is necessary because if we use some value to assign to a variable we have to return it back .but if we are not using any value then we write return 0
10th Jul 2016, 9:45 AM
piyush
0
return 0 means the function closed normally or was successful and any other no (1-999) mean that an error occurred. Simple program will work for any of the value as they have to compile only those small sentences but think of a complex program as soon as compiler will read other value than 0 it will stop there and not execute further sentences as for them any no other than 0 means an error occurred. and please avoid using VOID MAIN it's the wrong way to do.
10th Jul 2016, 9:16 PM
imnoob
imnoob - avatar
0
only main() function reaturn a velues so you have to write reaturn, otherwise you use void main() function
11th Jul 2016, 3:25 AM
Shubham Rathod
Shubham Rathod - avatar