plese explain about how return statement is used in the void function?
Return statement
are you taking about this return ??
this is not required
this will automatically return as nothing remain which is to be executed
return is jump statement it is used to stop execution of further line in a function
if you write return inside any function rest of he code (below return statement inside function) will not be executed
after return statement line of control move to calling function (form where current function is called)
Sir can we use return 0; in a void function instead of simply return; , if not then what is the difference between return , return 0, return 3 ?
void means you can’t return a value
but in void functions you can use return as a jump statement
in non void function with return type int
return 0, return 3
here 0,3 are values what ever you want to return you can
lets take one simple example
int add(int x,int y){
return x+y;
}
if x =0 y=1 it will return 1
if x=1 and y=2 it will return 3
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.