Which of the following declarations for a function is valid and legal in C++?

Select one:

a. void foo

b. All of the choices listed are valid C++ function declarations

c. int foo( char x );

d. None of the choices listed is a valid C++ function declaration

e. foo( int a, int b );

Respuesta :

Answer:

c. int foo( char x );

Explanation:

Among the given options:

int foo( char x );

is a valid function declaration which declares a function with the name foo which takes a single character argument x and returns an integer data type.

Option a (void foo) does not specify the arguments off the function while option e  (foo( int a, int b );) does not specify the return type.Hence these are incomplete function declarations.