[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Range of values in switch statement


Hi Experts,
I am not sure if I can do this in C++.  But, can I have a range in the switch statement.
Like the following.....

switch(val) {
 case 1 to 20:
     // do something
     break;
case 21 to 100:
    // do something
    break;
  // etc
}
     
0
thanesh
Asked:
thanesh
1 Solution
 
jkrCommented:
>>can I have a range in the switch statement.

That's not possible unfortunately, you'll have to resort to 'if' constructions or similar here.
0
 
thaneshAuthor Commented:
Thanks.  That is what I thought!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now