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

What is the value in result at the end of execution of each of these lines of
code? Each part is independent.
int x = 5;
int y = 7;
int z = 9;
int result = 0;

a. if (x < y)
result = z;

b. if (x==y)
result = z;
else
result = y;

c. if (z < x && x != y)
result = x;

d. if (z < x || x != y)
result = x;

e. if ( ! ( z >= x && y ==z)
result = x;

2007-03-23 14:01:31 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

a. result = 0; since x is less than y
b. result = 7; since x is not equal to y
c. result = 0; since false and true is false
d. result = 5; since false or true is true
e. result = 5; since not false is true

2007-03-23 15:21:47 · answer #1 · answered by ru_bled1010 2 · 0 0

just plug the numbers where the letters go

a: 5 is less than 7 so answer is 9
b: 7
c: 0
d: 5
e: 0

Let me know what you get on your homework...

2007-03-23 14:07:51 · answer #2 · answered by spl 4 · 0 0

fedest.com, questions and answers