Hi, how to convert the following switch statement to if-else statement
char ch;
switch(ch)
{
case 'w':cout<<"good";
case 's':cout<<"very good";
break;
case 'r':cout<<"very very good";
break;
case 'm':
case 'k':cout<<"best";
break;
default:cout<<"invalid";
break;
}
That is true. Switch executes all statements between first matching case and following break. Therefore, 'w' produces "goodvery good". That should be easy to test with the switch code version.