C - Operators - Discussion

You Are Here :: Home > C > Operators - Discussion

 



Q.

What will be output if you will compile and execute the following c code?

#include
void call(int,int,int);
int main(){
int a=10;
call(a,a++,++a);
return 0;
}
void call(int x,int y,int z){
printf("%d %d %d",x,y,z);
}
A. 10 10 12 B. 12 11 11
C. 12 12 12 D. 10 11 12

Answer: Option B
Explaination:

 


Default parameter passing scheme of c is cdecl i.e. argument of function will pass from right to left direction.

First ++a will pass and a=11
Then a++ will pass and a=11
Then a will pass and a=12







Discussion

Your Comments Goes here...
NameDiscussion