plz answer this question
Answers
The "return" statement can be optional. For example, when ' void' is used as a function, an operation is performed but it does not return any value. You may or not used the return statement here, as there no return value. Also, in cases when you not use the return statement, control will automatically return to the caller at the end of the statement.
- return:
In this statement, the return statement has no expression. This return statement can be used in cases when you have a function whose return type is ' void'. Such as:
void function() {
return;
}
This can be useful when you want to stop the flow of the function and jump out of it.
- return val
In this statement, val could be a variable and the value of val is returning back to the function.
hope it helped....
know more:
https://brainly.in/question/13124164 Uses of different statements in C program
The "return" can be optional when it is used in the void functions.
Explanation:
The return statement is used to stop the execution of the of a method and returns to the calling of the method. The method will immediately terminate when the return statement is executed.
The return statement is optional for the void methods. The void method will automatically returns when the end is reached.
Example: -
//function with no return type
void fun1(int a, int b)
{
int c = a+b;
cout<<"sum of a and b is: " << c <<endl;
//optional
return 0;
}
The return val statement determines that the function is returning some value. In this case the return statement is compulsory. The return type of the function is also required, the return type can be int, double, float etc. the function will return a int value if the return type of the function is int.
Example: -
//function will return a int value
int fun1(int a, int b)
{
int val = a + b;
//returning the sum of a and b
//return statement is necessary
return val;
}
Learn more: -
What is return statement? : - https://brainly.in/question/3596267
Definition of return statement in C: https://brainly.in/question/2003636