Assume a program contains a void function named displayName, which requires no formal parameters. Which of the following is a correct function prototype for this function? A. displayName; B. displayName(void); C. void displayName; D. void displayName(); E. void displayName(none);

displayName;
displayName(void);
void displayName;
void displayName(); E. void displayName(none);

The correct answer is: D. void displayName();

A function prototype is a declaration of a function that tells the compiler the

name of the function, the type of data it returns, and the types of data it expects as input. In this case, the function displayName does not return any data and does not take any input data, so its prototype is simply void displayName();.

The other options are incorrect because they either do not specify the return type of the function (A), or they specify the wrong return type (B, C, E).

Exit mobile version