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 are the different types of comments allowed in c++?
What is flush programming?
Is c++ double?
What is the c++ programming language used for?
Write a program to show polymorphism in C++?
What are references in c++?
Does a derived class inherit or doesn't inherit?
What is iomanip c++?
What return value must conversion operators have in their declaration?
Does c++ support multilevel and multiple inheritances?
What apps are written in c++?
Who made c++?