-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#8-Switch_Statement.dart
49 lines (43 loc) · 1.43 KB
/
#8-Switch_Statement.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
void main() {
//<-----------Control flow statement in Dart----------->
// (3)
//Switch Case Statement
//this control flow statement can be accesible when we have one value and we have to
//compare it to different value
//it works like ---->
// you have value and if the case 1 is = value then execute case 1 code if not then break the statement and check the second expression if not none of the condition match then exexute default statement .
/* Blueprint-->
switch(varriable){
case 1 :
//Execute the code
break;
case 2 :
//Execute the code
break;
case 3 :
//Execute the code
break;
deault :
//execute the code if nothing works
}
*/
// <!---impotant --!>
//in switch case statement only <- String and integer is allowed -> other datatypes like double boolean and null is not allowed .
String grade = 'A';
switch(grade){
case 'A' : //case 1
print("You Made it to the Top !"); //executable statement
break; //it breaks the code and go the next statement if the condition is not meet
case 'B' : //Case 2
print("You Got a Good Grade");
break;
case 'C' ://Case 3
print("Please Continue Hard Working ");
break;
case 'D' : //Case 3
print("You Failed !");
break;
default :
print('invalid input'); //Default statement or fallback statement
}
}