To find the output of the given program, let's go through each step:
- The variable
i
is initialized with a value of 5.
- The
printf
function is used to print the value of i=++i == 6
.
- The expression
++i
increments the value of i
by 1 before it is used in the comparison.
- The comparison
i == 6
checks if the incremented value of i
is equal to 6.
- The result of the comparison is assigned to
i
.
- The
printf
function prints the value of i
, which is the result of the comparison.
Now, let's analyze the expression i=++i == 6
:
- The variable
i
is incremented by 1, so its new value is 6.
- The comparison
6 == 6
evaluates to true, which is represented by the value 1.
- The value 1 is assigned to
i
.
Therefore, the value of i
is 1.
The correct answer is B) 1.