C - Functions - Discussion

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

 



Q.

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

void main(){
int a=10;
printf("%d %d %d",a,a++,++a);
}

A. 12 11 11 B. 12 10 10
C. 11 11 12 D. 10 10 12

Answer: Option D
Explaination:

In c printf function follows cdecl parameter passing scheme. In this scheme parameter is passed from right to left direction.So first ++a will pass and value of variable will be a=10 then a++ will pass now value variable will be a=10 and at the end a will pass and value of a will be a=12.



Discussion

Your Comments Goes here...
NameDiscussion