Professional Documents
Culture Documents
Module: Statements and Exceptions
Module: Statements and Exceptions
Contents
Introduction to Statements
Using Selection Statements
Using Iteration Statements
Using Jump Statements
Lab 4.1: Using Statements
Handling Basic Exceptions
Raising Exceptions
Lab 4.2: Using Exceptions
Introduction to
Statements
Algorithms
Any computing problem can be solved by
executing a series of actions in a specific
.order
A procedure for solving a problem in terms of
Types of Statements
Selection Statements
The if and switch statements
Iteration Statements looping statements
The while, do, for, and for each statements
Jump Statements
The go to, break, and continue statements
Selection Statements
Single IF
If students grade is
greater
than or equal to 60
Print Passed
if ( studentGrade >= 60 )
;Console.WriteLine( "Passed" )
If/Else
If students grade is
greater than or equal to
60 Print Passed
Else Print Failed
if ( studentGrade >= 60 )
;Console.WriteLine( "Passed" )
else
;Console.WriteLine( "Failed" )
Single IF
If/Else
Nesting if
Statements
If students grade is
greater than or equal
Print A
Else
If students grade is
greater than or equal
Print B
Else
If students grade is
greater than or equal
Print C
Else
If students grade is
greater than or equal
Print D
Else
Print F
to 90
to 80
to 70
to 60
if ( studentGrade >= 90 )
;Console.WriteLine( "A" )
else
if ( studentGrade >= 80 )
;Console.WriteLine( "B" )
else
if ( studentGrade >= 70 )
;Console.WriteLine( "C" )
else
if ( studentGrade >= 60 )
;Console.WriteLine( "D" )
else
;Console.WriteLine( "F" )
Iteration Statements
The while, do, for, and foreach statements
.are known as iteration statements
You use them to perform operations while
.a specific condition is true
do/while Repetition
Structure
;int counter = 1
do
}
Console.WriteLine( co
;unter )
++;counter
}
while ( counter <=
;5 )
do
}
statement
;while ( condition )}
Foreach Statement
Jump Statements
Break
Continue
98764321
END
THANK YOU