Answer to Question #263549 in C++ for DANISH

Question #263549

Determine whether the following are valid switch statements. If not,


explain why. Assume that n and digit are int variables. (11)



a. switch (n <5 2)


{


case 0:


cout << "Draw." << endl;


break;


case 1:


cout << "Win." << endl;


break;


case 2:


cout << "Lose." << endl;


break;


}






b. switch (digit / 4)


{


case 0,


case 1:


cout << "low." << endl;


break;


case 1,


case 2:


cout << "middle." << endl;


break;


case 3:


cout << "high." << endl;


}






c. switch (n % 6)


{


case 1:


case 2:


case 3:


case 4:


case 5:


cout << n;


break;


case 0:


cout << endl;


break;


}





d. switch (n % 10)


case 2:


{


case 4:


case 6:


case 8:


cout << "Even";


break;


case 1:


case 3:


case 5:


case 7:


cout << "Odd";


break;


}


1
Expert's answer
2021-11-11T00:06:49-0500

The correct answer is option C


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS