Can someone complete this c++ switch statement code. The two dashes are blank and it needs to be answered to complete the code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone complete this c++ switch statement code. The two dashes are blank and it needs to be answered to complete the code.

The output should be "Error" Switch (x){ case 1: cout<<"One"; break; case 2: cout<<"Two"; break; __: cout<<"Error"; } } Note that the output should display "Error"

27th Dec 2022, 11:08 AM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar
2 Answers
+ 1
Let me try..
27th Dec 2022, 1:17 PM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar
0
I would assume the last part with error is a catch for things not matching any other case. Thus I would imagine a default case is needed. Keyword default.
27th Dec 2022, 11:51 AM
Bloody Halos
Bloody Halos - avatar