What is wrong with the following function definition?
test_function (int k)
{
float temp = 5.34
temp = k / 2.0
return temp;
}
Answers
Answered by
0
If this question asks for function definition then after int k u should give an semicolon(;). Otherwise the statement is not ended by an terminator after temp declaration in first 2 lines inside the functions.
Answered by
0
Wrong with the following function definition:
- Although the given function is missing a return type in the function signature, it works fine and without any errors.
- But it does cause ambiguity in returning the variable temp.
- Although temp is defined as a float when it divides an integer k say 5 by 2 it is bound to have two results.
- First is an integer result, which is 2 and second is a floating-point result that is 2.5.
- In the absence of the return type, the function returns an integer while on the other hand, when the return type is specified as a float, it returns temp as a float.
Learn More About function definition:
Process of linking the function call
https://brainly.in/question/12609985
The function definition and first level refinement
https://brainly.in/question/4283470
Similar questions