Professional Documents
Culture Documents
Programming Languages Lecture-14 Fall-2022
Programming Languages Lecture-14 Fall-2022
Lecture-14
Corse Title: Programming Language
Course Code: EL-255
Course Teachers: Dr. Sadia Muniza Faraz
Semester: Fall-2022
Offered to: S.E. (Electronic Engineering)
Chapter-4
Conditions
1
12/19/2022
Conditional Statement
max=(num1 > num2) ? num1:num2;
for(i=1,i<=5,i++)
{
cout<< “\n enter integer”;
cin>> num;
max=(max > num) ? max:num;
}
2
12/19/2022
Switch Case
In if-else / else-if ass the number of alternatives
increases the complexity of program increases
drastically.
• Switch statement is a multi-way decision
statement
3
12/19/2022
Switch Case
if(Condition 1) switch ( expression )
Statement 1 {
else case label1 :
{ body1
Statement 2 break;
if(condition 2)
{ case label2 :
if(condition 3) body2
statement 3 break;
else case label3 :
if(condition 4) body3
{ break;
statement 4 default :
} default-body
} break;
else }
{
statement 5 next-statement;
}
7
}
4
12/19/2022
THE END