+ 2
Quotations?
Do you need quotation marks around numbers when using the switch statement. For example: case â1â: or case â2â
1 Answer
+ 9
If you're checking agaiast a string, use double quotes. Ex:
case "Yes": case "yes":
For char inputs, use single quotes. Ex:
case 'Y': case 'y':
case '1': //This checks for the character '1', not the number!
For numbers (int, double, etc.), don't use quotes.
case 1:
By the way, welcome to the SoloLearn Q&A, Peter! ^_^
Here's our posting guidelines, if you're interested:
https://www.sololearn.com/discuss/321242/?ref=app
https://www.sololearn.com/Discuss/593497/?ref=app
https://www.sololearn.com/Discuss/333866/?ref=app