2. Statement is instruction
that execute at run
time
Type of statements
1. Sequential statement
2. Conditional statement
3. iterative/looping
statement
4. Branching statement
3. Sequential
statement
• These are those
statements which
execute starting from
line1 to line 2 and so on.
• Till now the programs
we have done are
example of sequential
statements as
lines/statements in
programs are executed
in the sequence as
4. Conditional
statement
• Are those statements which will depend
on condition for their execution.
Types of Conditional Statements
• If condition
• if-else condition
• Nested if-else
• If-else ladder
6. WAP to find greatest of 2
numbers using if
condition
• lvalue : An expression that is an
lvalue may appear as either the left-
hand or right-hand side of an
assignment.
way2ITec
h
9. if-else
condition
• if evaluates to true. It does nothing
when the expression evaluates to
false.
• Else is used when we want some
statements to be executed when if
evaluates to be false. So if the
condition is true, if is executed else
, else is executed.
15. Nested if-
else
• if-else construct within either the body
of the if statement or the body of an
else statement or both. This is called
nesting‘of ifs.
18. If-else
Ladder
• It is used to check multiple
conditions.
• Every else is associated with its
previous if.
• The last else goes to work only if all
the conditions fail.
• Even in else if ladder the last
else is optional.
19.
20. • WAP to calculate tax for entered salary.
If salary > 10000, tax is 2 %. If salary
lies between 5000 and 10000, tax is
1.5 %. If salary is in between 3000 to
5000 , Tax is 1 % and if salary is lesser
then 3000, Tax is 0%