Computer Science, asked by HyperV, 5 months ago

Suppose the return type of function f is void. Which one of the following statements is true?
(a) Function f does not contain a return statement
(b) Function f does not have parameters
(c) Function f returns a generic value
(d) Function f does not work correctly​

Answers

Answered by Oreki
1

(a) Function f does not contain a return statement.

Answered by jenisha145
0

Function f does not contain a return statement the following statements is true.

Explanation:

  • Return statement is not used in void return type functions: The void return type is used when a function does not return anything.
  • So, if the function specification has a void return type, there will be no return statement inside that function (generally).
  • If a function definition lacks a return statement, control is passed back to the calling function after the called function's last statement is executed.
  • The called function's return value is undefined in this scenario. It's a major error if the function has a return type other than void, and the compiler emits a warning diagnostic message.
  • This behaviour is acceptable if the function returns void, however it may be deemed poor style.
  • To make your goal obvious, use a simple return statement.
Similar questions