Lecture 04
Lecture 04
CSC103: Lecture#4
if-else statement (Revisited)
Syntax of if-else condition executing a set of
statements (i.e. block of statements)
If (condition)
{
statement-1;
statement-2;
……..
}
else
{
statement-1;
statement-2;
……..
}
Statements after if structure;
Common programming error
Missing brackets around a block: It is an
error to forget brackets around a block of if or
if-else statement
E.g. OR
If (condition) If (condition)
statement-1;
{
statement-2; statement-1;
statement-2;
Statement-2 is independent }
of the condition state (whether else
True or false). It will always statement-3;
execute. statement-4;