Professional Documents
Culture Documents
Lecture 3
Lecture 3
COMPUTER PROGRAMMING
if (Boolean expression)
statement(s) /will execute if the Boolean expression is true
Single Decision and Action with braces
if (Boolean expression )
{
statement(s) /will execute if the Boolean expression is true /
}
Either/Or Decision
if (Boolean expression )
{ statement(s) /will execute if the Boolean expression is
true
}
else
{ statement(s) will execute if the boolean expression is false
}
Flow Diagram (if/else)
Multiple Case Decision
int x = 10, y = 20; Multiple Case Decision
if (x != y)
{
if (ix< y)
{
Console.WriteLine(“x is less than y");
}
else if (x > y)
{
Console.WriteLine(“x is greater than y");
}
}
Else
Console.WriteLine(“x is equal to y");
Switch
Flow Diagram (Switch)
Differences between IF ad Switch