0% found this document useful (0 votes)
2 views6 pages

Chapter 11 (LProgramming Using Loop)

Uploaded by

indranilgupta1
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)
2 views6 pages

Chapter 11 (LProgramming Using Loop)

Uploaded by

indranilgupta1
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

Delhi Public School – Ruby Park, Kolkata

CLASS 6
Computer Science(2023-24)
Study Material

Chapter 11: Programming Using Loops


Loop: A loop is a statement that enables you to repeat a
sequence of statements until a particular condition is met.

Types of Loop:

 FOR….NEXT
 DO WHILE
 DO UNTIL

FOR….NEXT Loop: FOR ….NEXT is a type of loop used to repeatedly


execute a statement or a set of statements for the specified number of

times.

Syntax of FOR….NEXT Loop:

FOR Loop_counter = start To end

Statements to be repeated

NEXT Loop_counter
PROGRAMS for FOR-NEXT LOOP:

1) Write a program to print first 10 natural numbers using FOR Loop.

CLS

REM To print first 10 natural numbers.

FOR i = 1 TO 10

PRINT i

NEXT i

END
2) Write a program to print first 10 natural numbers in descending

order.

CLS

REM To print first 10 natural numbers in descending order.

FOR i = 10 TO 1 STEP -1

PRINT i

NEXT i

END

3) Write a program to print odd numbers till 25.

CLS

REM To print odd numbers till 25.

FOR i = 1 TO 25 STEP 2

PRINT i

NEXT i

END
DO WHILE LOOP

DO WHILE LOOP: The DO WHILE Loop repeats a set of statements


while the specified condition is true.

Syntax of DO WHILE Loop:

DO WHILE(condition)

Set of instructions

LOOP

PROGRAMS for DO WHILE LOOP:

4. Write a program to print first 10 natural numbers using DO WHILE


Loop.

CLS

REM To print first 10 natural numbers

LET i = 1

DO WHILE i <= 10

PRINT i

i=i+1

LOOP

END
5. Write a program to print and calculate the sum of first 50

numbers.

CLS

REM To print and calculate the sum of first 50 numbers.

LET S = 0

LET i = 1

DO WHILE i < 51

PRINT i

S=S+i

i=i + 1

LOOP

PRINT “The Sum is” ; S

END

DO UNTIL LOOP

DO UNTIL LOOP: The DO UNTIL Loop repeats a set of statements till


the specified condition is false.

Syntax of DO UNTIL LOOP:

DO UNTIL ( condition)

Set of instructions

LOOP
PROGRAMS for DO UNTIL LOOP:

6) Write a program to print first 10 natural numbers using DO UNTIL

Loop.

CLS

REM To print first 10 natural numbers

LET i = 1

DO UNTIL i = 11

PRINT i

i=i+1

LOOP

END

You might also like