Using Range in C++ Switch Case Last Updated : 10 Dec, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In C++, we generally know about the switch case which means we give an attribute to the switch case and write down the cases in it so that for each case value we can make desired statements to get executed. We can also define the cases with a range of values instead of a single value. Prerequisites: Switch Case in C++Switch Case with RangeUsing range in switch case means in the above scenario we used to check only one value to the given attribute but now we can check a range of values to the given attribute in a single case So for using a range in the switch case let's refer to an example switch(a){ case '1': .....#some statements to execute case '2': ....#some another set of statements to execute.}In this case a is checked to 1 and 2 only know if we want to check it for numbers 1 to 100 and we have to print desired statements for them then we have to write 100 cases to check it .So its very long and instead we can use range in case as syntax mentioned below. Syntaxcase 'low' .. 'high': #set of statements to execute( low<high )Example with range in Switch Caseswitch(a){ case 1 ... 100 : // Statements case 101 ... 200: // Statements} Example of Using Range in C++ Switch CaseBelow is the implementation of the above topic: C++ // C++ Program to implement // Using Range in Swtich Case #include<iostream> using namespace std; // main function int main() { int a=8; // Switch Case switch(a) { // Range added to Switch case case 4 ... 10: cout<<"a is range 4 to 10"<<endl; break; } } Output : a is range 4 to 10Note:We have to exactly use 3 dots other wise it will give us error while compilation.If low>high then also we will get an error Comment More infoAdvertise with us Next Article Using Range in C++ Switch Case S shaikaltafhussain434 Follow Improve Article Tags : C++ Geeks Premier League Geeks Premier League 2023 Practice Tags : CPP Similar Reads Using Range in switch Case in C You all are familiar with switch case in C, but did you know you can use a range of numbers instead of a single number or character in the case statement? Range in switch case can be useful when we want to run the same set of statements for a range of numbers so that we do not have to write cases se 2 min read Switch case in R Switch case statements are a substitute for long if statements that compare a variable to several integral values. Switch case in R is a multiway branch statement. It allows a variable to be tested for equality against a list of values. Switch statement follows the approach of mapping and searching 2 min read switch vs if else Prerequisite - Switch Statement, Decision making(if else) A switch statement is usually more efficient than a set of nested ifs. Deciding whether to use if-then-else statements or a switch statement is based on readability and the expression that the statement is testing. Check the Testing Expressio 3 min read Switch Statement in C++ In C++, the switch statement is a flow control statement that is used to execute the different blocks of statements based on the value of the given expression. It is an alternative to the long if-else-if ladder which provides an easy way to execute different parts of code based on the value of the e 5 min read Output of C programs | Set 30 (Switch Case) Prerequisite - Switch Case in C/C++ Interesting Problems of Switch statement in C/C++ Program 1 C #include <stdio.h> int main() { int num = 2; switch (num + 2) { case 1: printf("Case 1: "); case 2: printf("Case 2: "); case 3: printf("Case 3: "); default: printf( 2 min read Like