0% found this document useful (0 votes)
3 views35 pages

Unit II Python Control Structures.

This document provides an overview of Python control structures, including sequential, selection, and repetition types. It explains various conditional statements such as if, if-else, and nested if statements, along with the use of logical operators and indentation in Python. Additionally, it covers iterative control structures like for and while loops, their syntax, and practical examples of their usage.

Uploaded by

Yasotha Priya
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 views35 pages

Unit II Python Control Structures.

This document provides an overview of Python control structures, including sequential, selection, and repetition types. It explains various conditional statements such as if, if-else, and nested if statements, along with the use of logical operators and indentation in Python. Additionally, it covers iterative control structures like for and while loops, their syntax, and practical examples of their usage.

Uploaded by

Yasotha Priya
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

UNIT II

PYTHON CONTROL STRUCTURES

According to the structure theorem, any computer program can be written using the basic control
structures . A control structure (or flow of control) is a block of programming that analyses
variables and chooses a direction in which to go based on given parameters. In simple sentence, a
control structure is just a decision that the computer makes. So, it is the basic decision-making
process in programming and flow of control determines how a computer program will respond
when given certain conditions and parameters.

Flow of control through any given program is implemented with three basic types of control
structures: Sequential, Selection and Repetition.

Sequential

Sequential execution is when statements are executed one after another in order..

Selection

Selection used for decisions, branching - choosing between 2 or more alternative paths.

 if
 if...else
 switch

Repetition

Repetition used for looping, i.e. repeating a piece of code multiple times in a row.

1
Unit II Control structures
 while loop
 do..while loop
 for loop

These control structures can be combined in computer programming. A sequence may


contain several loops; a loop may contain a loop nested within it, or the two branches of a
conditional may each contain sequences with loops and more conditionals. From the following
lessons you can understand the control structures and statements in Python language.

SELECTION CONTROL IF STATEMENTS:

PYTHON CONDITIONAL STATEMENTS

Decision making is one of the most important concepts of computer programming . It require
that the developer specify one or more conditions to be evaluated or tested by the program, along
with a statement or statements to be executed if the condition is determined to be true, and
optionally, other statements to be executed if the condition is determined to be
false. Python programming language provides following types of decision making statements.

 if statements
 if....else statements
 if..elif..else statements
 nested if statements
 not operator in if statement
 and operator in if statement
 in operator in if statement

PYTHON IF STATEMENTS

SYNTAX:

if expression:

statements

2
Unit II Control structures
In Python, if statement evaluates the test expression inside parenthesis. If test expression is
evaluated to true (nonzero) , statements inside the body of if is executed. If test expression is
evaluated to false (0) , statements inside the body of if is skipped.

EXAMPLE

x=20

y=10

if x > y :

print(" X is bigger ")

OUTPUT

X is bigger

PYTHON IF..ELSE STATEMENTS

The else statement is to specify a block of code to be executed, if the condition in the if statement
is false. Thus, the else clause ensures that a sequence of statements is executed.

3
Unit II Control structures
SYNTAX:

if expression:

statements

else:

statements

EXAMPLE:

x=10

y=20

if x > y :

print(" X is bigger ")

else :

print(" Y is bigger ")

OUTPUT:

Y is bigger

4
Unit II Control structures
IF..ELIF..ELSE STATEMENTS

SYNTAX:

if expression:

statements

elif expression:

statements

else:

statements

EXAMPLE:

x=500

if x > 500 :

print(" X is greater than 500 ")

elif x < 500 :

print(" X is less than 500 ")

elif x == 500 :

print(" X is 500 ")

else :

print(" X is not a number ")

OUTPUT:

X is 500

5
Unit II Control structures
MULTIWAY SELECTION -NESTED IF STATEMENTS

There are often times when selection among more than two sets of statements (suites) is needed.
For such situations, if statements can be nested, resulting in multi-way selection.

SYNTAX:

if condition:

if condition:

statements

else:

statements

else:

statements

The nested if statements on the right result in a 5-way selection. In the fi rst if statement, if variable
grade is greater than or equal to 90, then 'Grade of A' is displayed. Therefore, its else suite is not
executed, containing the remaining if statements. If grade is less than 90, the else suite is executed.
If grade is greater than or equal to 80, 'Grade of B' is displayed and the rest of the if statements in
its else suite are skipped, and so on. The fi nal else clause is executed only if all the previous
conditions fail, displaying 'Grade of F'. This is referred to as a catch-all case. As an example use
of nested if statements and a check for invalid input in a program.

If statements can be nested in Python, resulting in multi-way selection.

6
Unit II Control structures
EXAMPLE:

mark = 72

if mark > 50:

if mark > = 80:

print ("You got A Grade !!")

elif mark > =60 and mark < 80 :

print ("You got B Grade !!")

else:

print ("You got C Grade !!")

else:

print("You failed!!")

OUTPUT:

You got B Grade !!

NOT OPERATOR IN IF STATEMENT

By using Not keyword we can change the meaning of the expressions, moreover we can
invert an expression.

EXAMPLE:

mark = 100

if not (mark == 100):

print("mark is not 100")

else:

print("mark is 100")

O/P: mark is 100

7
Unit II Control structures
SAME CODE USING "!=" OPERATOR.

EXAMPLE:

mark = 100

if (mark != 100):

print("mark is not 100")

else:

print("mark is 100")

O/P:mark is 100

AND OPERATOR IN IF STATEMENT

The equivalent of "& & " is "and" in Python.

example

mark = 72

if mark > 80:

print ("You got A Grade !!")

elif mark > =60 and mark < 80 :

print ("You got B Grade !!")

elif mark > =50 and mark < 60 :

print ("You got C Grade !!")

else:

print("You failed!!")

O/P: You got B Grade !!

8
Unit II Control structures
IN OPERATOR IN IF STATEMENT

example

EXAMPLE:

color = ['Red','Blue','Green']

selColor = "Red"

if selColor in color:

print("Red is in the list")

else:

print("Not in the list")

O/P: Red is in the list

INDENTATION IN PYTHON

A header in Python is a specific keyword followed by a colon. the if-else statement contains
two headers, “if which == 'F':” containing keyword if, and “else:” consisting only of the keyword
else. Headers that are part of the same compound statement must be indented the same amount—
otherwise, a syntax error will result.

The set of statements following a header in Python is called a suite (commonly called a block ).
The statements of a given suite must all be indented the same amount. A header and its associated
suite are together referred to as a clause . A compound statement in Python may consist of one or
more clauses.

9
Unit II Control structures
Both (a) and (b) in the fi gure are properly indented. In (a), both suites have the same amount of
indentation. In (b), each suite has a different amount of indentation. This is syntactically correct
(although not good practice) since the amount of indentation within each suite is consistent. Both
(c) and (d) are examples of invalid indentation, and thus syntactically incorrect. In (c), the if and
else headers of the if statement are not indented the same amount. In (d), the headers are indented
the same amount. However, the statements within the second suite are not properly aligned.
Finally, note that the suite following a header can itself be a compound statement (another if
statement, for example). Thus, compound statements may be nested one within another.

A header in Python starts with a keyword and ends with a colon. The group of statements
following a header is called a suite. A header and its associated suite are together referred to
as a clause.

ITERATIVE CONTROL

10
Unit II Control structures
An iterative control statement is a control statement providing the repeated execution of
a set of instructions. An iterative control structure is a set of instructions and the iterative control
statement(s) controlling their execution. Because of their repeated execution, iterative control
structures are commonly referred to as “loops.” one specific iterative control statement is while
statement.

An iterative control statement is a control statement that allows for the repeated execution of a
set of statements.

There are two types of iteration:

o Definite iteration, in which the number of repetitions is specified explicitly in advance


o Indefinite iteration, in which the code block executes until some condition is met
 In Python, indefinite iteration is performed with a while loop.

PYTHON LOOPS

The flow of the programs written in any programming language is sequential by default.
Sometimes it needs to alter the flow of the program. The execution of a specific code may need to
be repeated several numbers of times., The programming languages provide various types of loops
which are capable of repeating some specific code several numbers of times.

WHY WE USE LOOPS IN


PYTHON?

The looping simplifies the complex


problems into the easy ones. It enables
us to alter the flow of the program so
that instead of writing the same code
again and again, we can repeat the same
code for a finite number of times. For
example, to print the first 10 natural
numbers then, instead of using the print
statement 10 times, it print inside a loop
which runs up to 10 iterations.

ADVANTAGES OF LOOPS

1. It provides code re-usability.

11
Unit II Control structures
2. Using loops, no need to write the same code again and again.
3. Using loops, To traverse over the elements of data structures (array or linked lists).

LOOP STATEMENTS IN PYTHON.

Loop Description
Statement

for loop The for loop is used in the case ,need to execute some part of the code until the
given condition is satisfied. The for loop is also called as a per-tested loop. It is
better to use for loop if the number of iteration is known in advance.

while loop The while loop is to be used in the scenario where we don't know the number
of iterations in advance. The block of statements is executed in the while loop
until the condition specified in the while loop is satisfied. It is also called a
pre-tested loop.

do-while The do-while loop continues until a given condition satisfies. It is also called
loop post tested loop. It is used when it is necessary to execute the loop at least once
(mostly menu driven programs).

PYTHON FOR LOOP

The for loop in Python is used to iterate the statements or a part of the program several times. It
is frequently used to traverse the data structures like list, tuple, or dictionary.

The syntax of for loop in python

for iterating_var in sequence:


statement(s)

12
Unit II Control structures
The for loop flowchart

FOR LOOP USING SEQUENCE

Example-1: Iterating string using for loop

str = "Python"
for i in str:
print(i)

13
Unit II Control structures
Output:

P
y
t
h
o
n

Example- 2: Program to print the table of the given number .

list = [1,2,3,4,5,6,7,8,9,10]
n=5
for i in list:
c = n*i
print(c)

Output:

5
10
15
20
25
30
35
40
45
50s

Example-4: Program to print the sum of the given list.

list = [10,30,23,43,65,12]
sum = 0
for i in list:
sum = sum+i
print("The sum is:",sum)

Output:

The sum is: 183

14
Unit II Control structures
FOR LOOP USING RANGE() FUNCTION

The range() function

The range() function is used to generate the sequence of the numbers. If pass the range(10), it
will generate the numbers from 0 to 9.

SYNTAX:

range(start,stop,step size)
o The start represents the beginning of the iteration.
o The stop represents that the loop will iterate till stop-1. The range(1,5) will generate
numbers 1 to 4 iterations. It is optional.
o The step size is used to skip the specific numbers from the iteration. It is optional to use.
By default, the step size is 1. It is optional.

Example-1: Program to print numbers in sequence.

for i in range(10):
print(i,end = ' ')

Output:

0123456789

Example - 2: Program to print table of given number.

n = int(input("Enter the number "))


for i in range(1,11):
c = n*i
print(n,"*",i,"=",c)

Output:

Enter the number 10


10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50

15
Unit II Control structures
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100

Example-3: Program to print even number using step size in range().

n = int(input("Enter the number "))


for i in range(2,n,2):
print(i)

Output:

Enter the number 20


2
4
6
8
10
12
14
16
18

Use the range() function with sequence of numbers. The len() function is combined with range()
function which iterate through a sequence using indexing.

list = ['Peter','Joseph','Ricky','Devansh']
for i in range(len(list)):
print("Hello",list[i])

Output:

Hello Peter
Hello Joseph
Hello Ricky
Hello Devansh

NESTED FOR LOOP IN PYTHON

Python allows us to nest any number of for loops inside a for loop. The inner loop is executed n
number of times for every iteration of the outer loop.

16
Unit II Control structures
SYNTAX

for iterating_var1 in sequence: #outer loop


for iterating_var2 in sequence: #inner loop
#block of statements
#Other statements

Example- 1: Nested for loop

# User input for number of rows


rows = int(input("Enter the rows:"))
# Outer loop will print number of rows
for i in range(0,rows+1):
# Inner loop will print number of Astrisk
for j in range(i):
print("*",end = '')
print()

Output:

Enter the rows:5


*
**
***
****
*****

Example-2: Program to number pyramid.


rows = int(input("Enter the rows"))
for i in range(0,rows+1):
for j in range(i):
print(i,end = '')
print()

Output:

1
22

17
Unit II Control structures
333
4444
55555

USING ELSE STATEMENT WITH FOR LOOP

Unlike other languages like C, C++, or Java, Python allows us to use the else statement with the
for loop which can be executed only when all the iterations are exhausted. Here, we must notice
that if the loop contains any of the break statement then the else statement will not be executed.

Example 1

for i in range(0,5):
print(i)
else:
print("for loop completely exhausted, since there is no break.")

Output:

0
1
2
3
4
for loop completely exhausted, since there is no break.

The for loop completely exhausted, since there is no break.

Example 2

for i in range(0,5):
print(i)
break;
else:print("for loop is exhausted");
print("The loop is broken due to break statement...came out of the loop")

The loop is broken due to the break statement; therefore, the else statement will not be executed.
The statement present immediate next to else block will be executed.

Output:

18
Unit II Control structures
The loop is broken due to the break statement...came out of the loop. We will learn more about
the break statement in next tutorial.

PYTHON WHILE LOOP

The Python while loop allows a part of the code to be executed until the given condition returns
false. It is also known as a pre-tested loop.

It can be viewed as a repeating if statement.

SYNTAX.

1. while expression:
2. statements

Here, the statements can be a single statement or a group of statements. The expression should be
any valid Python expression resulting in true or false. The true is any non-zero value and false is
0.

19
Unit II Control structures
WHILE LOOP FLOWCHART

LOOP CONTROL STATEMENTS

To change the normal sequence of while loop's execution using the loop control statement. When
the while loop's execution is completed, all automatic objects defined in that scope are demolished.
Python offers the control statement to use within the while loop.

1. Continue Statement - When the continue statement is encountered, the control transfer
to the beginning of the loop.

20
Unit II Control structures
Example:

# prints all letters except 'a' and 't'


i=0
str1 = 'javatpoint'

while i < len(str1):


if str1[i] == 'a' or str1[i] == 't':
i += 1
continue
print('Current Letter :', a[i])
i += 1

Output:

Current Letter : j
Current Letter : v
Current Letter : p
Current Letter : o
Current Letter : i
Current Letter : n

2. Break Statement - When the break statement is encountered, it brings control out of the loop.

Example:

1. # The control transfer is transfered


2. # when break statement soon it sees t
3. i = 0
4. str1 = 'javatpoint'
5.
6. while i < len(str1):
7. if str1[i] == 't':
8. i += 1
9. break
10. print('Current Letter :', str1[i])
11. i += 1

21
Unit II Control structures
Output:

Current Letter : j
Current Letter : a
Current Letter : v
Current Letter : a

3. Pass Statement - The pass statement is used to declare the empty loop. It is also used to
define empty class, function, and control statement.

Example -

1. # An empty loop
2. str1 = 'javatpoint'
3. i = 0
4.
5. while i < len(str1):
6. i += 1
7. pass
8. print('Value of i :', i)

Output:

Value of i : 10

Example-1: Program to print 1 to 10 using while loop


1. i=1
2. #The while loop will iterate until condition becomes false.
3. While(i<=10):
4. print(i)
5. i=i+1

Output:

1
2
3
4
5
6
7
8

22
Unit II Control structures
9
10

Example -2: Program to print table of given numbers.


1. i=1
2. number=0
3. b=9
4. number = int(input("Enter the number:"))
5. while i<=10:
6. print("%d X %d = %d \n"%(number,i,number*i))
7. i = i+1

Output:

Enter the number:10


10 X 1 = 10

10 X 2 = 20

10 X 3 = 30

10 X 4 = 40

10 X 5 = 50

10 X 6 = 60

10 X 7 = 70

10 X 8 = 80

10 X 9 = 90

10 X 10 = 100

INFINITE WHILE LOOP

If the condition is given in the while loop never becomes false, then the while loop will never
terminate, and it turns into the infinite while loop.

23
Unit II Control structures
Any non-zero value in the while loop indicates an always-true condition, whereas zero indicates
the always-false condition. This type of approach is useful if we want our program to run
continuously in the loop without any disturbance.

Example 1
1. while (1):
2. print("Hi! we are inside the infinite while loop")

Output:

Hi! we are inside the infinite while loop


Hi! we are inside the infinite while loop

Example 2
1. var = 1
2. while(var != 2):
3. i = int(input("Enter the number:"))
4. print("Entered value is %d"%(i))

Output:

Enter the number:10


Entered value is 10
Enter the number:10
Entered value is 10
Enter the number:10
Entered value is 10
Infinite time

USING ELSE WITH WHILE LOOP

Python allows us to use the else statement with the while loop also. The else block is executed
when the condition given in the while statement becomes false. The else statement is optional to
use with the while loop.

24
Unit II Control structures
Example 1

i=1

while i < 6:

print(i)

i += 1

else:

print("i is no longer less than 6")

1
2
3
4
5
i is no longer less than 6

Example 2
1. i=1
2. while(i<=5):
3. print(i)
4. i=i+1
5. if(i==3):
6. break
7. else:
8. print("The while loop exhausted")

Output:

1
2

In the above code, when the break statement encountered, then while loop stopped its execution
and skipped the else statement.

Example-3 Program to print Fibonacci numbers to given limit


1. terms = int(input("Enter the terms "))
2. # first two intial terms

25
Unit II Control structures
3. a = 0
4. b = 1
5. count = 0
6.
7. # check if the number of terms is Zero or negative
8. if (terms <= 0):
9. print("Please enter a valid integer")
10. elif (terms == 1):
11. print("Fibonacci sequence upto",limit,":")
12. print(a)
13. else:
14. print("Fibonacci sequence:")
15. while (count < terms) :
16. print(a, end = ' ')
17. c=a+b
18. # updating values
19. a=b
20. b=c
21.
22. count += 1

Output:

Enter the terms 10


Fibonacci sequence:
0 1 1 2 3 5 8 13 21 34

PYTHON BREAK STATEMENT

The break is a keyword in python which is used to bring the program control out of the loop. The
break statement breaks the loops one by one, i.e., in the case of nested loops, it breaks the inner
loop first and then proceeds to outer loops. In other words, break is used to abort the current
execution of the program and the control goes to the next line after the loop.

The break is commonly used in the cases where need to break the loop for a given condition.

26
Unit II Control structures
The syntax of the break is

1. #loop statements
2. break;

Example 1

1. list =[1,2,3,4]
2. count = 1;
3. for i in list:
4. if i == 4:
5. print("item matched")
6. count = count + 1;
7. break
8. print("found at",count,"location");

Output:

item matched
found at 2 location

Example 2

1. str = "python"
2. for i in str:
3. if i == 'o':
4. break
5. print(i);

Output:

p
y
t
h

Example 3: break statement with while loop

1. i = 0;
2. while 1:

27
Unit II Control structures
3. print(i," ",end=""),
4. i=i+1;
5. if i == 10:
6. break;
7. print("came out of while loop");

Output:

0 1 2 3 4 5 6 7 8 9 came out of while loop

Example 3

1. n=2
2. while 1:
3. i=1;
4. while i<=10:
5. print("%d X %d = %d\n"%(n,i,n*i));
6. i = i+1;
7. choice = int(input("Do you want to continue printing the table, press 0 for no?"))
8. if choice == 0:
9. break;
10. n=n+1

Output:

2X1=2

2X2=4

2X3=6

2X4=8

2 X 5 = 10

2 X 6 = 12

2 X 7 = 14

2 X 8 = 16

28
Unit II Control structures
2 X 9 = 18

2 X 10 = 20

Do you want to continue printing the table, press 0 for no?1

3X1=3

3X2=6

3X3=9

3 X 4 = 12

3 X 5 = 15

3 X 6 = 18

3 X 7 = 21

3 X 8 = 24

3 X 9 = 27

3 X 10 = 30

Do you want to continue printing the table, press 0 for no?0

PYTHON CONTINUE STATEMENT

The continue statement in Python is used to bring the program control to the beginning of
the loop. The continue statement skips the remaining lines of code inside the loop and start with
the next iteration. It is mainly used for a particular condition inside the loop so that it can skip
some specific code for a particular condition..

SYNTAX
1. #loop statements
2. continue
3. #the code to be skipped

29
Unit II Control structures
Flow Diagram

Example 1
1. i = 0
2. while(i < 10):
3. i = i+1
4. if(i == 5):
5. continue
6. print(i)

Output:

1
2
3
4
6
7
8
9
10

30
Unit II Control structures
Observe the output of above code, the value 5 is skipped because it provided the if condition using
with continue statement in while loop. When it matched with the given condition then control
transferred to the beginning of the while loop and it skipped the value 5 from the code.

Example 2
1. str = "JavaTpoint"
2. for i in str:
3. if(i == 'T'):
4. continue
5. print(i)

Output:

J
a
v
a
p
o
i
n
t

PASS STATEMENT

The pass statement is a null operation since nothing happens when it is executed. It is used in the
cases where a statement is syntactically needed but we don't want to use any executable statement
at its place.

For example, it can be used while overriding a parent class method in the subclass but don't want
to give its specific implementation in the subclass.

Pass is also used where the code will be written somewhere but not yet written in the program file.
Consider the following example.

Example
1. list = [1,2,3,4,5]
2. flag = 0
3. for i in list:
4. print("Current element:",i,end=" ");
5. if i==3:
6. pass

31
Unit II Control structures
7. print("\nWe are inside pass block\n");
8. flag = 1
9. if flag==1:
10. print("\nCame out of pass\n");
11. flag=0

Output:

Current element: 1 Current element: 2 Current element: 3


We are inside pass block

Came out of pass

Current element: 4 Current element: 5

Python Pass

In Python, the pass keyword is used to execute nothing; it means, when we don't want to execute
code, the pass can be used to execute empty. It is the same as the name refers to. It just makes the
control to pass by without executing any code. If we want to bypass any code pass statement can
be used.

It is beneficial when a statement is required syntactically, but we want we don't want to execute
or execute it later. The difference between the comments and pass is that, comments are entirely
ignored by the Python interpreter, where the pass statement is not ignored.

Suppose we have a loop, and we do not want to execute right this moment, but we will execute
in the future. Here we can use the pass.

Example - Pass statement

Example - 1

1. for i in [1,2,3,4,5]:
2. if(i==4):
3. pass
4. print("This is pass block",i)
5. print(i)

Output:

32
Unit II Control structures
1
2
3
This is pass block 4
4
5

INPUT ERROR CHECKING

The while statement is well suited for input error checking in a program

The program continues to prompt the user until a valid temperature conversion, 'F' or 'C', is entered.
Thus, the associated input statement is contained within a while loop that keeps iterating as long
as variable which contains an invalid value. Once the user enters a proper value, the loop terminates
allowing the program to continue.

n = 10
sum = 0
current = 1
while current <5 n:
sum = sum + current
current = current + 1
print(sum)
???
n = 10

33
Unit II Control structures
sum = 0
current = 1
while current <5 n:
sum = sum + current
current = current + 1
print(sum)
???
The while statement is well suited for input error checking.

INFINITE LOOPS

An infinite loop is an iterative control structure that never terminates (or eventually terminates
with a system error). Infinite loops are generally the result of programming errors. For example,
if the condition of a while loop can never be false, an infinite loop will result when executed.

Such infinite loops can cause a program to “hang,” that is, to be unresponsive to the user. In such
cases, the program must be terminated by use of some special keyboard input (such as ctrl-C) to
interrupt the execution..

An infinite loop is an iterative control structure that never terminates

DEFINITE VS. INDEFINITE LOOPS

A definite loop is a program loop in which the number of times the loop will iterate can be
determined before the loop is executed.

sum = 0
current = 1
n = input('Enter value: ')
while current , 5 n:

34
Unit II Control structures
sum = sum + current
current = current+ 1

Although it is not known what the value of n will be until the input statement is executed, its value
is known by the time the while loop is reached. Thus, it will execute “n times.”

An indefinite loop is a program loop in which the number of times that the loop will iterate cannot
be determined before the loop is executed. Consider the while loop in the temperature conversion
program of Figure 3-19.

which =input("Enter selection: ")


while which ! = 'F' and which ! 5 'C':
which = input("Please enter 'F' or 'C': ")

In this case, the number of times that the loop will be executed depends on how many times the
user mistypes the input. Thus, a while statement can be used to construct both definite and indefi
nite loops.

A definite loop is a program loop in which the number of times the loop will iterate can be
determined before the loop is executed.
A indefinite loop is a program loop in which the number of times the loop will iterate is not
known before the loop is executed.

35
Unit II Control structures

You might also like