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 Posted / 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 View All Answers
List the issue that the auto_ptr object handles?
How would you use qsort() function to sort an array of structures?
Why should you learn c++?
What is buffer and example?
What is wrapper class in c++?
Mention the storage classes in c++.
Can we use struct in c++?
What are all predefined data types in c++?
What is implicit pointer in c++?
What does it mean to declare a member function as virtual?
Is it possible for a member function to delete the pointer, named this?
What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00
What are the c++ access specifiers?
Is map thread safe c++?
What things would you remember while making an interface?