






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























Lecture No. 8
In the last lecture
Multi-way decision
if ( grade ==โAโ ) cout << โ Excellent โ ; if ( grade ==โBโ ) cout << โ Very Good โ ; if ( grade ==โCโ ) cout << โ Good โ ; if ( grade ==โDโ ) cout << โ Poor โ ; if ( grade ==โFโ ) cout << โ Fail โ ;
if Statements
if ( grade == โAโ )
cout << โ Excellent โ ;
else if ( grade == โBโ )
โฆ
else if โฆ
โฆ
else โฆ
if else
switch statement
switch ( grade) { case โAโ : cout << โ Excellent โ ; case โBโ : cout << โ Very Good โ ; case โCโ : โฆ โฆ }
switch statements
switch statements
Example
switch ( grade ) { case โAโ : cout << โ Excellent โ ; break ; case โBโ : cout << โ Very Good โ ; break ; case โCโ : cout << โGood โ ; break ; case โDโ : cout << โ Poor โ ; break ; case โFโ : cout << โ Fail โ ; break ; }
switch (grade)
Display โExcellentโ case โBโ :
case โAโ :
Display โVery Goodโ
Default :
โโฆโฆ..โ
โฆ
if ( amount > 2335.09 )
statements ;
case โAโ :
case โ 300 โ :
case โ f โ :
if (c == โzโ )
{ cout << โ Great! You have made the correct guess โ ; break ; }
break ;