C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 2)
2.
Which of the following statement is correct?
C++ enables to define functions that take constants as an argument.
We cannot change the argument of the function that that are declared as constant.
Both A and B.
We cannot use the constant while defining the function.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
10 comments Page 1 of 1.

Prabhat said:   1 decade ago
If argument is constant. Then what is the need of having argument.

Function without argument can serve the purpose.
(1)

Aleyan said:   1 decade ago
Constant can not change their values and if argument is constant we can not change argument value.

Hari said:   1 decade ago
If arguments fixed as constants that can not be changed.

Sowmya said:   1 decade ago
Once the arguments are declared as constants that can't to change its value in any execution. Even in function.

Shiv said:   1 decade ago
Constant = The variable having fixed value is called as constant.

Hence, constant can not change their values.

And function takes variable as an argument.

Constant is a type of variable.

i.e. Option C is correct.

TvdZ said:   1 decade ago
Technically B is incorrect, as a const_cast would allow you to change a constant.

Bhaumik said:   1 decade ago
Its not change the argument type. We can change its value which type of argument is there. So arguments type is constant.

Navya said:   10 years ago
Why we cannot use the constant while defining function?
(1)

Samala sumanth said:   8 years ago
Can mutable change the value of const?

Matiyas ginbaru said:   2 years ago
Statement A: C++ enables defining functions that take constants as arguments.

In C++, you can declare function parameters as constants using the const keyword. This allows you to pass constant values or variables as arguments to the function.

Statement B: Functions that are declared with parameters as constants cannot modify the values of those parameters. When a function parameter is declared as const, it signifies that the function will not alter the value of the parameter. This restriction ensures that the function does not inadvertently modify the passed argument.

Therefore, both statements A and B are correct, so, the correct answer is C.
(3)

Post your comments here:

Your comments will be displayed after verification.