0% found this document useful (0 votes)
45 views10 pages

Cs112 - Programming Fundamental: Lecture # 19 - Iterative Control in C Syed Shahrooz Shamim

This document discusses iterative control in C programming through loops. It defines looping as repeatedly executing a sequence of statements until a termination condition is met. There are three main types of loops in C - while loops, do-while loops, and for loops. Loops can be classified as entry-controlled (like while and for loops), where the termination condition is checked before the loop body executes, or exit-controlled (like do-while loops), where the body executes unconditionally first before the condition is checked. Some example uses of while loops are provided.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views10 pages

Cs112 - Programming Fundamental: Lecture # 19 - Iterative Control in C Syed Shahrooz Shamim

This document discusses iterative control in C programming through loops. It defines looping as repeatedly executing a sequence of statements until a termination condition is met. There are three main types of loops in C - while loops, do-while loops, and for loops. Loops can be classified as entry-controlled (like while and for loops), where the termination condition is checked before the loop body executes, or exit-controlled (like do-while loops), where the body executes unconditionally first before the condition is checked. Some example uses of while loops are provided.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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