Given the following seqment of code containing a group of
nested if instructions: y = 9; if ((x==3) || (x == 5)) y++;
else if (x == 2) y *= 2; else if (x == 4 ) y-= 7; else y =
8; Enter a segment of code (without any IF statements) that
does exectly the same thing using the switch structure.
Answer / isha
y=9;
switch(x)
{
case 2:y*=2;
break;
case 3:
case 5: y++;
break;
case 4:y-=7;
break;
default:y=8;
}
| Is This Answer Correct ? | 2 Yes | 0 No |
What is the difference between mutex and binary semaphore?
What is this weird colon-member (" : ") syntax in the constructor?
What is the extraction operator and what does it do?
How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)
Explain how overloading takes place in c++?
Explain class invariant.
What would happen on forgetting [], while deallocating an array through new?
What are maps in c++?
What is virtual base class uses?
Define token in c++.
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16