0

Return in c++

can anyone plz tell me what is the difference between return,return 1,return 0

17th Dec 2016, 2:40 AM
Pi Piscine
Pi Piscine - avatar
1 Answer
0
return : the name its self suggest that return something ..to function let me explain you by example when your write normal program int main () { return 0; } main () is integer value type to the operating system. Therefore every main () should end with return 0 as you can see in above program , otherwise warning may occurs. return 0 to main tell operating system program successful completed . coming to function : return plays an important role in function. int foo() { return 2; } float fun() { return 1.23; } int main () { float h=fun() int m =foo(); cout<<foo(); cout <<fun(); return 0; } output h= 1.23 m=2 2 1.23 above program gives u clear idea about return note that void function no return type . example: void fun () { } coming to your question. return :- plain return doesn't return any value return value or expression :- which returns value or expression to function Hope I answered your question....
17th Dec 2016, 4:22 AM
Mock
Mock - avatar