Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

CS112 - PROGRAMMING FUNDAMENTAL

Lecture # 19 – Iterative Control in C


Syed Shahrooz Shamim
Junior Lecturer,
CS Department, UIT
ITERATIVE CONTROL
Iterative Statements
Looping
• In looping, a sequence of statements are executed
until some condition is satisfied which is placed for
termination of the loop
• A program loop consists of two segments
• body of the loop
• the control statement
• The control is tested always for execution of the
body of the loop
Iterative Statements
How loop works
Iterative Statements
• Loops may classified as:
• entry-controlled loop
• exit-controlled loop
Entry Controlled Loop
• The control conditions
are tested before the start
of the loop execution.
• If the conditions are not
satisfied , then the body
of the loop will not be
executed.
• Entry controlled loop is
also known as pre-test
loop.
• Example: – While Loop
for Loop
Exit Controlled Loop
• The Test is performed at
the end of the body of
the loop and there fore
the body is executed
unconditionally for the
first time.
• Exit controlled loop is
also known as post-test
loop.
• Ex- ->Do-While
Types of loop
There Are three types of loops in C:
• While loop
• Do-while loop
• For loop
While Loop
While Loop
Example
1. Program to print first 10 numbers
2. Program to add first 10 numbers
3. Program to add first 10 even numbers
4. Program to add first 10 odd numbers

You might also like