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.



Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3..

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

Post New Answer

More C++ General Interview Questions

What does it mean to declare a destructor as static?

0 Answers  


Is python written in c or c++?

0 Answers  


what are the iterator and generic algorithms.

0 Answers  


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

0 Answers  


What is a responder chain?

0 Answers  






Why c++ is better than c language?

0 Answers  


What is a driver program?

0 Answers  


What is the difference between "overloading" and "overridding"?

3 Answers  


Is vector a class in c++?

0 Answers  


What are Binay tress and B trees? Diff between them?

8 Answers   CTS, GATE, Wipro,


When do we use copy constructors?

0 Answers  


What is a storage class? Mention the storage classes in c++.

0 Answers  


Categories