Programming Languages C Objective
Mar 08, 2013

What will be output of the following c code?
void main()
{
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
}

Choose the correct answer:
A) 12
B) 21
C) 13
D) Compiler error
Detailed Explanation

In ++a, ++ is pre increment operator. In any mathematical expression pre increment operator first increment the variable up to break point then starts assigning the final value to all variable.
Step 1: Increment the variable I up to break point.
Step 2: Start assigning final value 7 to all variable i in the
expression.
So, i=7+7+7=21

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback