183k views
0 votes
What will be stored in variables a, b after the following statements are executed?int a, b = 1;a = b++; (Note: ? means that we don't know what value is stored in a variable.)

1 Answer

3 votes

Final answer:

After executing the statement 'a = b++;', the variable 'a' will have the value 1, and the variable 'b' will be incremented to 2.

Step-by-step explanation:

The question is about understanding post-increment operator in programming, specifically in the C programming language. When the expression a = b++ is executed, two operations occur. First, the current value of b (which is 1) is assigned to a. After that, b is incremented by 1. So after the statement is executed, the value of a will be 1, and the value of b will be 2.

User Flegare
by
7.7k points