Programming in C
Pop Quiz
Increment and Decrement operators - Questions
For questions 1 through 2, assume the following code:
int a;
int b;
a=1;
b=a++;
- What value does the variable b have after ALL of the
code above executes?
- 1
- 2
- 3
- unknown/undefined
- What value does the variable a have after ALL of the
code above executes?
- 1
- 2
- 3
- unknown/undefined
For questions 3 through 5, assume the following code:
int x;
int y;
int z;
x=3;
y=4;
z = ++x * y++;
- What value does the variable z have after ALL of the
code above executes?
- 9
- 12
- 16
- unknown/undefined
- What value does the variable x have after ALL of the
code above executes?
- 2
- 3
- 4
- unknown/undefined
- What value does the variable y have after ALL of the
code above executes?
- 4
- 5
- 6
- unknown/undefined
See the answers.
Return to the CS 222 Home Page.
Return to David's Home Page.
Return to Cayuga's Home Page.