The label and the result of the control expression in a swit
Solution
Answer - 1
switch(expr)
{
case label1:
// .....
break;
// ....
}
switch always successively compares the value of expr the value of labels
and labels can be either integer constant or charecter constant.
Thus, label can not bet float in a switch statement.
Again, result of a control expression can be either have value 0 (zero) or non zero value
but both the values are integer constant.
Thus, result of a control expression in a switch statement can not bet float.
So, answer of question 1 is True.
Answer - 2
Given a = 0 , b = 0
|| ( OR ) operator results in true whenever one of its two operands is 1 but here both the
operands such that a and b has value equals to 0 so that result of ( a || b ) is false.
! ( NOT ) operator results in true whenever its input is false otherwise results in false.
Here, input to the NOT ( ! ) operator is false as ( a || b ) is false so that result should
be true.
Thus !(a || b) is true.
So, answer of question 2 true.
Answer - 3
Given a = 0 , b = 0
Precedence of operator >= is greater than operator ||
Thus, the expression a || b >= 2 is equivalent to this expression a || ( b >= 2)
Here, (b >= 2) results in 0 (zero) as b is neither equals to 2 nor greater than 2.
|| ( OR ) operator results in true whenever one of its two operands is 1.
So, after executing (b >= 2) the expression a || ( b >= 2 ) changes to a || 0 and also the value
of a is 0 , thus a || 0 results in false.
Thus a || b >= 2 is false. (not equals to true)
So, answer of question 3 is false.
Answer - 4
continue statement transfer control directly to control expression with executing the rest part
after continue statement.
Example -
for(int i=0;i<10;i++)
{
if(i==5)
{
continue;
cout<<\"\ Hello World\ \";
}
else
{
cout<<\"\ Titan\ \";
}
}
Now, for i equals to 5 the if statement will be executed but as in the if block there is a continue
statement the \'Hello World\' will not be printed as continue statement transfer control directly to
for loop.
Thus, the continue statement is never used to terminate a loop.
So, answer of question 4 is false.

