switch 2fcase with numeric range

Solutions on MaxInterview for switch 2fcase with numeric range by the best coders in the world

showing results for - "switch 2fcase with numeric range"
Capucine
16 Jan 2021
1int i = 63;
2
3switch (i)
4{
5    case int n when (n >= 100):
6        Console.WriteLine($"I am 100 or above: {n}");
7        break;
8
9    case int n when (n < 100 && n >= 50 ):
10        Console.WriteLine($"I am between 99 and 50: {n}");
11        break;
12
13    case int n when (n < 50):
14        Console.WriteLine($"I am less than 50: {n}");
15        break;
16}
Camilla
19 Aug 2019
1function getCategory(age) {  
2    var category = "";  
3    switch (true) {  
4        case isNaN(age):  
5            category = "not an age";  
6            break;  
7        case (age >= 50):  
8            category = "Old";  
9            break;  
10        case (age <= 20):  
11            category = "Baby";  
12            break;  
13        default:  
14            category = "Young";  
15            break;  
16    };  
17    return category;  
18}  
19getCategory(5);  // will return "Baby"
queries leading to this page
switch with range c 23switch statement range of numbersc 23 switch int rangeswitch statement c 23 for intervalrange switch case c 23switch case with range of numberc 23 case switch rangebetween in switch case c 23case 3e 3d in c 23how to make a switch for greater than a number in c 23switch statement for range value c 23print the numbers between to number in switch case in c 23c 23 if number is in range switch case c 23 switch case rangec 23 net switch between valuesc 23 switch conditional rangecount geater than 2 in switch case c 23switch c 23 case rangeswitch case range valueswitch case c 23 rangec 23 range switchswitch range in c 23switch case with number rangeswitch statement with between vales c 23how to put ranges in c 23 switch caserange values for case switch c 23case range c 23switch statement number rangec 23 switch rangeswitch case string c 23range operator in a switch c 23switch case between range of numbershow to switch a range of numbersc 23 case statement integer rangesswitch ranges c 23c 23 switch on rangesswitch case if number smaller c 23c 23 switch statement numberswitch case c 23case syntax c 23 can add range 3fc 23 case 1 99c 23 switch case with rangec 23 switch case range of numbersswitch case c 23 rangescheck number than switch case in c 23switch statement with int c 23 rangeswitch case value between c 23c 23 switch case int rangeswitch range case c 23range of numbers in switchc 23 switch range of valuesswitch case number rangerange based switch c 23switch case rangeswitch case with rangerange in switch c 23c 23 if case is over number 5cc 23 case rangeswitch case javac 23 switch statement for range of numbersc 23 switch case last possible numberc 23 switch case with range of valuesrange values for case switchc 23 case statement if case is between valuesswitch statements c 23 for number rangec 23 case between 10 and 50switch case range c 23c 23 switch case 3e5using switch case with ranges c 23switch case for rangeswitch 2fcase with numeric rangec 23 switch with range intif int is int switch case c 23switch statement with int range c 23switch number rangeswitch range c 23switch case c 23 define rangec 23 switch between 3 values depending on a floatswitch 2fcase with numeric range