Ask Question

Which of the following is a valid function prototype for the following function definition?

void TotalAmount (int a, float &b, string name); { / / ... }

a) void TotalAmount (int, float, string);

b) void TotalAmount (int &, float &, string &);

c) void TotalAmount (int, float &, string);

Answers (1)
  1. 4 November, 20:38
    The answer is "Option c"


    In the given function code, a TotalAmount function is declared, which includes three-parameter, which are "integer, float, and string", and function return type is void, which means, it doesn't return any value. In these parameters a float variable is a reference type, that uses "&", that's why it is correct and other options were not correct, that can be explained as follows:

    In option a, In this function parameter, a variable is not a reference type variable, that's why it is not correct. In option b, In this function, all parameter value is a reference type that's why it is not correct.
Know the Answer?