If the following code is legal, what can we infer about the return type of f?
double d = f() [n]
The return type of the function f is of type double. The logic is a follows:
- The statement is trying to define a variable double d. i.e. a variable called d of type double.
- The equal (=) sign assigns whatever that is on the right (of the equal sign), to the left (of the equal sign).
- As we know that the left-hand-side is of type double, it must be true that the right must also be of type double.
- Hence, the return type of the function f, is indeed of type double.