206k views
5 votes
Which of the following function prototypes are not valid?

a) void doSomething(int& x, int y);
b) void doSomething( int& x, int& y);
c) void doSomething( int x, int y);
d) all are valid

User Dave Moten
by
7.0k points

1 Answer

1 vote

Final answer:

All the function prototypes listed (a, b, and c) are valid in programming. The prototypes include variations with reference parameters and value parameters, and both styles are acceptable function declarations.

Step-by-step explanation:

The question is regarding the validity of certain function prototypes in programming. Function prototypes are used to declare a function before its actual implementation to ensure correct function calls. A prototype typically specifies the function's name, return type, and parameters. Looking at the provided options:

  • a) void doSomething(int& x, int y);
  • b) void doSomething(int& x, int& y);
  • c) void doSomething(int x, int y);
  • d) all are valid

All of these function prototypes are valid. The first two options use reference parameters (denoted by the ampersand '&'), which means that the function will modify the original argument passed. The third option takes values by copy, so changes made to the parameters within the function will not affect the original arguments. The student can thus be assured that none of the function prototypes a, b, or c are invalid.

User Alexander Beletsky
by
8.3k points