switch case in c We studied earlier in decision control that how and when to use if, if-else. They are good enough to select one from the two available options. When choices are two, we can use if-else. Even if we have multiple choices we can use multiple if-else, sometimes we use if-else ladder or nested if-else becomes more complex. Whenever we have many choices(cases) and we have to choose one of them(generally), it is better to use switch case control. In this section we are going to learn three keywords, case and default. Apart from these keywords we will also see usage of break keyword in switch body. Syntax switch case in c Switch statement is used to solve multiple option type problems for menu like program, where one value is associated with each option. The expression in switch case evaluates to return an integral value, which is then compared to the values in different cases, where it matches that block of code is executed, if there is no match, then def...
Comments
Post a Comment