Chapter - 4: Functions

Suppose there is a function with the following prototype:


C
Sections
3
Exercises

void f (int = 10, int = 20, int = 30, int = 40)

If this function is called by passing 2 arguments to it, how can we make sure that these arguments are treated as first and third, whereas, the second and the fourth are taken as defaults?


Ans: When we pass the values in a function with default arguments, so the values get assigned from left to right. There's no other way so that we could skip an argument and passed to its right as said in the question. So it is not possible that we pass value and arguments are treated as first and third, whereas, the second and the fourth are taken as defaults.


© 2021 Garbage Valuegarbage value logo