Selection Statements
A selection statement selects statements depending on the value of a controlling expression. The selection statements are the if and switch statement.
IF Statement
An example of an IF statement is the following.
If (i<1)
funct(i);
else
{
i =x++;
funct(i) ;
}
Explaining this is much easier than it looks. First of all i is just the name given to an integer. The first line reads if i is less than 1. The second line says else which means if the integer isn't less than 1. The fifth line says if the integer is more than 1 then the 6th line shows another function will occur. So in short if the integer is less than 1 then a designated function will happen however if it is more than 1 then another designated function will occur.
Switch Statement
A switch statement executes at least 1 cases which is based on the controlling expression.
If then elseaa- End if
Switch/case
No comments:
Post a Comment