Here the parameter passing mechanism is pass by reference. Any change done to the parameter will be reflected outside the function. So, the value of b, after the exit of the function will be 10.
Object Oriented Programming MCQ - Functions
Here the function chg tries to change the parameter x, which is not allowed as it is declared to be a constant integer. So, the compiler gives an error.
As such C does not support pass by reference. But it can be simulated by using pointers.
Macros do not have an address associated with them as they are processed by the pre-processor.
They cannot be passed as arguments to a function, etc. Also, macros are replaced in a blind manner without any regard to the context which may result in a stupid code, like
#define mul(a,b) a*b
The macro call mul(a, b + 1) will be expanded as a *b+ 1, but our intention was to get a * (b+ 1 ) .
They cannot be passed as arguments to a function, etc. Also, macros are replaced in a blind manner without any regard to the context which may result in a stupid code, like
#define mul(a,b) a*b
The macro call mul(a, b + 1) will be expanded as a *b+ 1, but our intention was to get a * (b+ 1 ) .
It should randomly generate any integer between 1 and 6. rand( ) % 6 returns an integer from 0 to 5. To make it 1 to 6, we need to add 1

