English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What is the value of x upon completion of the following statements?
int x,y,z;
x = 12;
y = 13;
z = 14;
if ( (z == 13) || (z > y)) {
x = x+3;
} else {
x = x+4;
}

2007-11-12 04:29:32 · 2 answers · asked by Nick L 1 in Science & Mathematics Mathematics

2 answers

15.
z == 13 is false. z>y is true
so (z==13 || (z>y) ) is (false || true)
Which is true if either one is true. So the code after the if statement runs, not the else statement

2007-11-12 04:35:18 · answer #1 · answered by Demiurge42 7 · 1 0

x=15
z = 13 or z > y : Here z > y, so x=x+3=12+3

2007-11-12 04:36:23 · answer #2 · answered by cidyah 7 · 0 0

fedest.com, questions and answers