© Manzur
Ashraf
Objective:
Learn the selection structures.
Scope:
The student should know the following:
1. One-Way if
if (guess==magic) printf("Right");
2. Two-Way if
if (expression) {
statement1;
}
else {
statement 2;
}
OR, expression? stmt1:stmt2
example: x=10;
y= x>9 ? 100 : 200;
3. Nested if
if (exp1) stmt1;
else if (expr2) stmt2;
else if (expr3) stmt3;
else stmt4;
4.
Switch
case constant1: stmt sequence
break;
case constant2: stmt sequence
break;
case constant3: stmt sequence
break;
.
.
default: stmt sequence
}
Discussion:
The following problem will be discussed:
Exercises:
Evaluation:
Your grade will depend on
your active participation and seriousness during the lab.