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 |
Is there any difference between dlearations int* x and int *x? If so tell me the difference?
What are the extraction and insertion operators in c++? Explain with examples.
What are the rules about using an underscore in a c++ identifier?
What are proxy objects?
What is object oriented programming (oop)?
What is pure virtual function?
what Is DCS ? what i will get benefit when i did?
difference between c and c++?
38 Answers Cognizant, IBM, Infosys, Oracle, Sarva Shiksha Abhiyan, Wipro,
What is cloning?
What is constructor c++?
Write a function to find the nth item from the end of a linked list in a single pass.
Which c++ operator cannot overload?