Question: Given the following if - else code segment.if ( ( x = = 1 ) ) name ( = ) John;else

Given the following if-else code segment.if \((x==1)\)name \(=\) "John";else if \((x==2)\)name \(=\) "George";elsename = "Unknown";Which of the following choices is a correct translation of the if-else statement to a switch statement in \(\mathrm{C}++\)?Choice 3:switch \((x)\{\)case 1: name = "John"; break;case 2: name = "George"; break;case 3: name = "Unknown"; break;\}Choice 4:switch \((x)\{\)case 1: name = "John"; break;case 2: name = "George";default: name = "Unknown"; break;\}Choice 2:switch \((x)\{\)case 1: name = "John";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!