![]() ![]() The break keyword in each case indicates the end of a particular case.As soon as a case is found the block of statements associated with that particular case is executed and control goes out of the switch. This value is compared with all the cases until case whose label four is found in the program. Suppose the test expression contains value 4. Whenever the switch is executed, the value of test-expression is compared with all the cases which we have defined inside the switch.A block is nothing but multiple statements which are grouped for a particular case. ![]() Each of these cases is associated with a block. Case labels always end with a colon ( : ).This creates problems in the program and does not provide the desired output. Then while executing the program, the case that appears first will be executed even though you want the program to execute a second case. Suppose we have two cases with the same label as ‘1’. Remember that case labels should not be same as it may create a problem while executing a program. Value-1, 2, n are case labels which are used to identify each case individually.The expression can be integer expression or a character expression.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |