Question
Question 1 (8 points): Choose the Correct Answer (2 points for each question) 1. What are...

Answers
1.
int x=0, y=2;
if(x==0)
{ y=1;}
else
{ y=2;}
since initial value before if condition evaluation of x is 0, the if condition is satisfied (true)
and thus the code inside if block executes .. therefore y is assigned a value 1.
since if condition was true, else block won't be executed
therefore, the values of x and y afterwards will be (a) x=0, y=1;-----------------------------------------------------
2. (a) this will output "Yes" because both the conditions are satisfied and with the OR operator, even if one is satisfied, it will be true
(b) this will output "Yes" only for num=5, the if condition will be false for as greater than equal to 5 is false when num is 2 or 3 or 4
(c) this will output "Yes" as both the conditions will always be true for num=2 or 3 or 4 or 5
(d) compilation error, number can't be compared this way together with two conditions
-----------------------------------------------------
3. 0
The second if clause is nested inside the first if clause
and the else condition will correspond to the second nested if clause onlyFirst if condition is not satisfied as x=9 so x can't be less than 5
therefore none of the statements further are executed and the value of y remains 0.-----------------------------------------------------
4. (b) 0 2
x-- will decrement the value of x by 1 after using the previous value of x for calculation (as this is port decrement operator)
thus, x's value is 1 for calculation y= 1* 2
so, y =2
and then x will be decremented to 0.