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 Posted / 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 |
Post New Answer View All Answers
Define copy constructor.
What is diamond problem in c++?
Why do we use setw in c++?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
what Is DCS ? what i will get benefit when i did?
What are exceptions c++?
Is java based off c++?
What will happen if a pointer is deleted twice?
What are the uses of c++ in the real world?
How can we check whether the contents of two structure variables are same or not?
Difference between overloaded functions and overridden functions
Differentiate between declaration and definition.
What is a dynamic binding in c++?
Can static member variables be private?
Explain deep copy?