0% found this document useful (0 votes)
3 views

Lec 08 Flowchart - Loop control structure

The document provides an overview of loop control structures in programming, explaining their purpose, types, and flowchart representations. It details entry-controlled loops (For and While) and exit-controlled loops (Do-While), along with common mistakes in creating loop flowcharts. Additionally, it includes practice exercises for implementing loops in flowcharts, such as calculating sums, displaying multiplication tables, and counting digits.

Uploaded by

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

Lec 08 Flowchart - Loop control structure

The document provides an overview of loop control structures in programming, explaining their purpose, types, and flowchart representations. It details entry-controlled loops (For and While) and exit-controlled loops (Do-While), along with common mistakes in creating loop flowcharts. Additionally, it includes practice exercises for implementing loops in flowcharts, such as calculating sums, displaying multiplication tables, and counting digits.

Uploaded by

anaskhabeer04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

FLOWCHARTS

Loop Control Structure


Introduction to Loop Control
Structures
Definition: Loops are used to repeat a set of
instructions until a condition is met.
Purpose:
• Automates repetitive tasks.
• Saves time and reduces errors.
Examples:
For Loop
While Loop
Do While Loop
Types of Loops in Programming
1. Entry-Controlled Loops:
• For Loop: Repeats for a fixed number of iterations.
• While Loop: Repeats while the condition is true.
2. Exit-Controlled Loops:
• Do-While Loop: Executes at least once before
checking the condition.
Flowchart Symbols for Selection
Control
• Decision Symbol (Diamond): Condition checks,
branching into Yes/No or True/False.
• Process Symbol (Rectangle): Represents steps to be
repeated.
• Arrows: Show the flow of logic and repetition.

• Tip: Always clearly mark the loop-back arrows.


Flowchart for a For Loop
• Explanation: Used for a fixed number of
iterations.
• Structure:
• Initialize counter.
• Check condition.
• Execute block.
• Increment counter.
• Example: Print numbers 1 to 5.
• Print numbers 3,5,7.
5
Example Flowchart: For Loop

6
Flowchart for a While Loop
• Explanation:Repeats steps while the condition
is true.
• Structure:
• Check condition.
• Execute block.
• Repeat or Exit.
• Example: Sum numbers until the total exceeds
50.
7
Example Flowchart: While Loop

8
Flowchart for a Do-While Loop
• Explanation:Executes steps at least once
before checking the condition.
• Structure:
• Execute block.
• Check condition.
• Repeat or Exit.
• Example: Display “Hello!” until a user enters
“Stop”.
9
Example Flowchart: Do-While
Loop
Common Mistakes in Loop
Flowcharts
• Forgetting termination or increment steps.
• Creating infinite loops with incorrect
condition checks.
• Missing loop-back arrows or unclear
conditions.
Practice Exercise

1. Printing numbers 1 to 10.


2. Calculating the sum of numbers from 1 to 10.
3. Prompting the user until they enter a valid password.
Practice Exercise
◼ Practice Exercise 1: Calculate the Sum of N Numbers
• Task: Create a flowchart that takes a positive integer N as input
and calculates the sum of all numbers from 1 to N.
• Hint: Use a for loop to iterate through numbers from 1 to N
and keep adding to a total.
◼ Practice Exercise 2: Display Multiplication Table
• Task: Design a flowchart to display the multiplication table of a
given number N up to 10.
• Hint: Use a for loop to multiply N by numbers 1 through 10.
Practice Exercise
◼ Practice Exercise 3: Find the Factorial of a Number
• Task: Draw a flowchart that calculates the factorial of a given
number N.
• Hint: Use a while loop to multiply numbers from N down to 1.
◼ Practice Exercise 4: Count Digits in a Number
• Task: Create a flowchart that takes a number as input and counts
the number of digits it has.
• Hint: Use a while loop to repeatedly divide the number by 10
until it becomes 0.
Practice Exercise
◼ Practice Exercise 5: Count Even and Odd Numbers
• Task: Create a flowchart to take NNN numbers as input
and count how many are even and how many are odd.
• Hint: Use a for loop with a condition inside to check each
number.

You might also like