Sail E0 Webinar
Question

What will be output if you compile following c code ?


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


Options:
A .  12 11 11
B .  12 10 10
C .  11 11 12
D .  10 10 12
E .  compile error
Answer: Option B

In c printf function follows cdecl parameter passing scheme. In this scheme parameter is passed from right to left direction.

So 1st step ++a will pass and value a = 10 will get printed




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers