Which of the following statement(s) is/are correct regarding void keyword in…
20212021
Which of the following statement(s) is/are correct regarding void keyword in C++? I. To specify the return type of a function when it is not returning any value. II. To indicate an empty argument list to a function.
- A.
Only I
- B.
Only II
- C.
Both I and II
- D.
Neither I nor II
Attempted by 156 students.
Show answer & explanation
Correct answer: C
In C++, the void keyword is used in multiple ways:
To specify that a function does not return any value.
Example:
void display()
To indicate that a function has no arguments.
Example:
int show(void)Since both statements are correct, the correct answer is Both I and II.