answersLogoWhite

0


Best Answer

There is only one comma, but it is not used in switch-case. Character literals are between apostrophes: 'x'

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which comma is used for characters in switch case statements?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How can we use characters in the switch statements to select the cases java?

Switch statements in Java can only use integer values. This means that we can switch on char values (because chars are simply ints with a different output type), but we can not switch on Strings or any other objects. The following examples are both valid in Java. // switch 1 int x = 1; switch(x) { case 0: break; case 1: break; default: break; } // switch 2 char x = '1'; switch(x) { case '0': break; case '1': break; default: break; }


What is the similarity between 'if' statement ans 'switch' statement?

A Switch statement can be considered as a series of if. else if. else statements. whatever condition is satisfied, the code block would get executed. if (cond 1) { } else if (cond 2) { } else if (cond 3) { } ...... } else if (cond N) { } else { } switch { case 1: .... case 2: .... .... case N: ... default: ... } Difference: In the if else blocks, if one condition is satisfied, all other blocks are ignored In Switch blocks, unless you have break statements inside each condition block, the subsequent blocks would not be ignored.


What are the disadvantages of switch statement in C-language?

In some languages and programming environments, a case or switch statement is considered easier to read and maintain than an equivalent series of if-else statements, because it is more concise. However, when implemented with fall-through, switch statements are a frequent source of bugs among programmers new to the switch statement.


The statement can cause other statements to execute under certain conditions?

Selection statement: if, switch/case, ternary conditional operator.


What is compared with the value that follows each of the case statements when a switch statement executes?

The expression in the switch statement is evaluated. The result of this evaluation is then compared with each case statement in turn until a matching case is found, which then forces a jump to the appropriate case. Execution then continues from that point until a break, return or goto statement is encountered, or execution falls through the switch statement.

Related questions

How can we use characters in the switch statements to select the cases java?

Switch statements in Java can only use integer values. This means that we can switch on char values (because chars are simply ints with a different output type), but we can not switch on Strings or any other objects. The following examples are both valid in Java. // switch 1 int x = 1; switch(x) { case 0: break; case 1: break; default: break; } // switch 2 char x = '1'; switch(x) { case '0': break; case '1': break; default: break; }


How do you use a switch statement in GML?

Switch Statements are used to generate different outputs of code based on the value of an expression. Switch Statements work as follows:{randomNumber = floor(random(3))+1;switch(randomNumber) {case 1: { } break;case 2: { } break;case 3: { } break;default: { } break;}}This may seem confusing if you are new to GML, so I will give an in-depth explanation. The first line sets the variable randomNumber to a random number between 0 and 2, and adds it by 1 to make it a random number from 1-3. So far the only thing that has gone on in the code is to set a variable to either 1, 2, or 3. This is where the switch statement comes in.switch(randomNumber) {case 1: { } break;case 2: { } break;case 3: { } break;default: { } break;}this is the actual switch statement. You may be wondering what the case statements are for. case statements are always written inside switch statements and do nothing anywhere else. case statements activate when the expression in the switch statement is the same as the value that they are assigned to. Take a look at this switch statement:{rand = floor(random(3));switch(rand) {case 0: {show_message("The Random Value Was 0");} break;case 1: {show_message("The Random Value Was 1");} break;case 2: {show_message("The Random Value Was 2");} break;}} When the values assigned to the case statements are equal to the expression in the switch statement, the case statement will run the code contained in it's brackets. break statements order the switch statement to abort. The reason that you need break statements inside a switch statement is because it keeps the other cases from activating as well. (When one case statement activates, the others do as well.)A final briefing on switch statements is that they are not limited to variables. Take a look at this switch statement.{switch(obj_block.x > x) {case true: {show_message("The Block Is Ahead Of You.");} break;case false: {show_message("You Are Ahead Of The Block.");} break;}} This switch statement returns a true or false value, and the case statements operate accordingly.


What is the similarity between 'if' statement ans 'switch' statement?

A Switch statement can be considered as a series of if. else if. else statements. whatever condition is satisfied, the code block would get executed. if (cond 1) { } else if (cond 2) { } else if (cond 3) { } ...... } else if (cond N) { } else { } switch { case 1: .... case 2: .... .... case N: ... default: ... } Difference: In the if else blocks, if one condition is satisfied, all other blocks are ignored In Switch blocks, unless you have break statements inside each condition block, the subsequent blocks would not be ignored.


What are the disadvantages of switch statement in C-language?

In some languages and programming environments, a case or switch statement is considered easier to read and maintain than an equivalent series of if-else statements, because it is more concise. However, when implemented with fall-through, switch statements are a frequent source of bugs among programmers new to the switch statement.


What is the use of switch statement in java?

In java, a switch statement is used to simplify a long list of 'if' statements. A switch statement takes the form of:switch (variableName){case condition1; command1;case condition2; command2;...}


Is there a comma after In this case?

No, a comma is not needed after "In this case" unless it is followed by a clause or parenthetical element that requires punctuation.


The statement can cause other statements to execute under certain conditions?

Selection statement: if, switch/case, ternary conditional operator.


How to make decision making statements in c plus plus?

Decision making statements make use of conditional expressions. In C++ there are three possibilities: if/else, switch/case and the ternary operator (?:).


Do you use a comma after unfoertunately?

I would expect a comma to be used, unfortunately, this is not always the case!


How do you make a program that would display menu of arithmetic choices and have the loop continue until the chooses to quit in c plus plus?

You can accomplish this using do-while loop and switch statement. Here is an example:int choice;do{cout


What does shift key do?

Toggle switch mostly. Many keys do 2 characters like upper/lower case


What is compared with the value that follows each of the case statements when a switch statement executes?

The expression in the switch statement is evaluated. The result of this evaluation is then compared with each case statement in turn until a matching case is found, which then forces a jump to the appropriate case. Execution then continues from that point until a break, return or goto statement is encountered, or execution falls through the switch statement.