ICSE Class 10 Computer Applications
Question 4 of 30
Solved Sample Paper 1 — Question 4
Back to all questions 4
Question Question 1(iv)
Assume x = 1 with the following code snippet:
int y = --x;Which one of the following is true?
- x = 1, y = 1
- x = 0; y = 0
- x = 1; y = 0
- x = 0; y = 1
x = 0; y = 0
Reason — Prefix decrement operator first decrements and then uses the value. Thus, the value of x will be decremented first (making x = 0) and then the value will be assigned to y (making y = 0).