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 access specifiers in C++?
Why is c++ difficult?
Explain the difference between static and dynamic binding of functions?
Ask to write virtual base class code?
What size is allocated to the union variable?
Difference between pointer to constant vs. Pointer constant
What is an operator function? Describe the function of an operator function?
Write a program to calculate the BMI of a person using the formula BMI = weight/height2.
if there is binary tree which one is the easiest way to delete all child node?
Where do I find the current c or c++ standard documents?
Should I learn c++ c?
In C++ cout is: a) object b) class c) something else
11 Answers Infosys, Lehman Brothers,