Google News
logo
CPP - Quiz(MCQ)
Where should default parameters appear in a function prototype?
A)
Middle of the parameter list
B)
Anywhere inside the parameter list
C)
To the rightmost side of the parameter list
D)
To the leftmost side of the parameter list

Correct Answer :   To the rightmost side of the parameter list


Explanation : Default parameters are defined to the rightmost side of parameter list in a function to differentiate between the normal and default parameters for example if a function is defined as fun(int x = 5, int y) then if we call fun(10) then 10 should be given to x or y because one can apply both logics like x = 10 already defined and 10 passed is for y but if compiler reads it from left to right it will think it is for x and no parameter is given for y, therefore, the compiler will give error.

Advertisement