QUESTION 1 Which expression is evaluated first in the following statement? if (a
ID: 3741469 • Letter: Q
Question
QUESTION 1
Which expression is evaluated first in the following statement?
if (a > b && c == d || a == 10 && b > a * b)?
a * b
b && c
d || a
a > b
none of the above
QUESTION 2
What is the output for total after the following segment of code executes?
int num = 3, total = 0;
switch (num)
{
case 1:
case 2:
total = 5;
break;
case 3:
total = 10;
break;
case 4:
total = total + 3;
break;
case 8:
total = total + 6;
break;
default:
total = total + 4;
break;
}
WriteLine("The value of total is " + total);
The value displayed for total would be . If num had been initialized to 100, would be displayed. If num was initialized to 1, would be displayed.
QUESTION 3
Assuming the following declarations:
int a is 5,
b is 6,
c is 8;
which of the result of each of the expressions. Identify the result of each of the expressions.
a. a == 5;_________________
b. 7 <= (a + 2); ___________
c. c <= 4;____________
d. (1 + a) != b; ____________
e. a >= 0; ___________
f. a <= (b * 2); ____________
a * b
b && c
d || a
a > b
none of the above
QUESTION 2
What is the output for total after the following segment of code executes?
int num = 3, total = 0;
switch (num)
{
case 1:
case 2:
total = 5;
break;
case 3:
total = 10;
break;
case 4:
total = total + 3;
break;
case 8:
total = total + 6;
break;
default:
total = total + 4;
break;
}
WriteLine("The value of total is " + total);
The value displayed for total would be . If num had been initialized to 100, would be displayed. If num was initialized to 1, would be displayed.
Explanation / Answer
Answer:
a > b
Since () is left to right precedence. When we are moving from left to right in () , we encounter a> b first.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.