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 |
Can you please explain the difference between static and dynamic binding of functions?
What does ctime() do?
Why should we use null or zero in a program?
What is a storage class used in c++?
What is abstract keyword in c++?
What is the difference between prefix and postfix versions of operator++()?
In a class only declaration of the function is there but defintion is not there then what is that function?
Are vectors faster than arrays?
Is c++ low level?
What is the difference between public, private, protected inheritance?
Can union be self referenced?
differance between copy & clon