The expression c = i++ causes

the value of i assigned to c and then i incremented by 1
i to be incremented by 1 and then the value of i assigned to c
value of i assigned to c
i to be incremented by 1 E. None of the above

The correct answer is B.

The expression $c = i++$ is a pre-increment expression. This means that the value of $i$ is incremented first, and then the new value of $i$ is assigned to $c$.

Here is an example:

“`
int i = 1;
int c = i++;

printf(“%d\n”, i); // prints 2
printf(“%d\n”, c); // prints 1
“`

In this example, the value of $i$ is first incremented to 2, and then the new value of $i$ (2) is assigned to $c$. This means that $c$ now contains the value 1.

Here is another example:

“`
int i = 1;
int c = i++;

printf(“%d\n”, i); // prints 2
printf(“%d\n”, c); // prints 2
“`

In this example, the value of $i$ is first incremented to 2, and then the new value of $i$ (2) is assigned to $c$. However, the value of $i$ is still 2 after the expression is evaluated. This is because the value of $i$ is only incremented once, after the expression is evaluated.

I hope this helps!

Exit mobile version