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 does it mean to declare a destructor as static?
Is python written in c or c++?
what are the iterator and generic algorithms.
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
What is a responder chain?
Why c++ is better than c language?
What is a driver program?
What is the difference between "overloading" and "overridding"?
Is vector a class in c++?
What are Binay tress and B trees? Diff between them?
When do we use copy constructors?
What is a storage class? Mention the storage classes in c++.