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 |
Define pre-condition and post-condition to a member function in c++?
What is the difference between shallow copy and deep copy?
What is an operator in c++?
What is abstraction with real time example?
What is the output of: String a1 = "Hello"; String a2 = "world!"; String* s1 = &a2; String& s2 = a1; s1 = &a1; s2 = a2; std::cout << *s1 << " " << s2 << std::endl;
What operators can you overload in c++?
How can you find the nodes with repetetive data in a linked list?
What is an explicit constructor?
What parameter does the constructor to an ofstream object take?
What are the advantages of using typedef in a program?
What is a constructor initializer list and when we use constructor initializer list?
Which is better c++ or java?