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 is c++ hash?

0 Answers  


Define linked lists with the help of an example.

0 Answers  


how to access grid view row?

0 Answers  


What is a concrete class?

1 Answers  


Can I learn c++ in a week?

0 Answers  






What is data binding in c++?

0 Answers  


What is the stack?

5 Answers   IBM, ICICI,


Explain the uses oof nested class?

0 Answers  


What is the purpose of the "delete" operator?

0 Answers  


What operators can you overload in c++?

0 Answers  


What is the use of seekg in c++?

0 Answers  


How many types of classes are there in c++?

0 Answers  


Categories