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 Pure Virtual Function? Why and when it is used ?
When can I use a forward declaration?
What do you mean by abstraction in C++?
Explain the uses oof nested class?
Explain calling an object's member function(declared virtual)from its constructor?
What it is and how it might be called (2 methods).
What does it mean to declare a member function as virtual?
What are punctuators in c++?
how to create window program in c++.please explain.
Write about the local class and mention its use?
Describe private, protected and public?
Can you pass a vector to a function?