Question: Consider the following code snippet. int apple = 10; int banana = 10; int carrot = 20; switch ( apple ) { case banana: //

Consider the following code snippet.

int apple = 10; int banana = 10; int carrot = 20; switch ( apple ) { case banana: // Code break; case carrot: // Code break; default: // Code break; } 

What is wrong?

A. The case statement must contain an integral value (integer or char). The variables banana and carrot are not allowed as case values..
B. The variables apple, banana and carrot are not accessible in the switch block.
C. The switch block is incomplete. At least one valid c++ code statement is required in all case statements, not including the break statement.

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!