In this lecture, I was lectured about selections program control in programming. We can use these following methods:
- If
- Switch Case
- "?:" Operator
The use is kinda alike, for each of every methods it is mostly like this:
Syntax:
if(condition){
statement; //This is for true value
statement;
......
}
else {
statement; //This is for false value
statement;
........
}
For Switch Case it goes this way:
Syntax:
switch(Variable):
case 'condition' : statement; //this is kind of like first "if" on the case
......
break;
case 'condition' : statement; //this is the second selection if the value doesn't have true value on the first one
........
break;
case default : break; //this is for if on every case shows false value
No comments:
Post a Comment