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

Class-8 Ict Ppt Q-basic

The document provides an overview of Q Basic programming, focusing on loops, including FOR...NEXT and DO...WHILE loops. It includes examples of how to write programs to display numbers, names, and calculate sums using these loops. Additionally, it contains hands-on questions and homework assignments related to the concepts discussed.

Uploaded by

Anshuman Mohanty
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)
1 views

Class-8 Ict Ppt Q-basic

The document provides an overview of Q Basic programming, focusing on loops, including FOR...NEXT and DO...WHILE loops. It includes examples of how to write programs to display numbers, names, and calculate sums using these loops. Additionally, it contains hands-on questions and homework assignments related to the concepts discussed.

Uploaded by

Anshuman Mohanty
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/ 20

Q Basic

Write a program to display number 1


to 20 using print command.
SOURCE CODE

CLS
PRINT 1
PRINT 2
PRINT 3
PRINT 4
....
PRINT 20
END
LOOPING
IN
Q BASIC
Learning Objectives:-

•Understand what loops are


and why they needed.

•Different types of loop


statement.

•Understand for loop and while


loop used in the program.

•Be able to design & code


WHAT IS LOOPING

A loop is a sequence of
instruction i.e. continually
repeated until a certain
condition is reached.

Or

A loop is a programming
function that iterates a
statement or condition based
on specified boundaries.
Loops can repeat in two ways:

1. A specific number of
times. FOR...NEXT Loops

2. Until a certain condition is


met. DO while,do loop
while, do until Loops
FOR…..NEXT LOOP:
SYNTAX:
FOR COUNTER_VARIABLE = STARTVALUE TO ENDVALUE
STEP STEPVALUE
(Statement of Loop)
NEXT COUNTER_VARIABLE
Example:

Write a program to display your BEST


FRIENDS’ NAME 5 times USING FOR
NEXT LOOP.

CLS
FOR A=1 TO 5 STEP 1
PRINT “ARYAN”
NEXT A
END
WRITE A PROGRAM T DISPLAY THE SUM OF
NUMBER FROM 1 TO 20.

CLS
Sum=0;
FOR A =1 TO 20 STEP 1
SUM =SUM +A
NEXT A
END
DO….WHILE LOOP:
 A DO….WHILE loop is used when we
want to repeat a set of statements as long
as condition is true.

The condition usually results from a


comparison of two values, but it can be
any expression that evaluates to a
Boolean value (TRUE or FALSE).

The condition checked at the beginning


of the loop
The Syntax of DO….WHILE loop
statement is as follows:
DO WHILE (TEST CONDITION)
(Statements Of Loop)
LOOP
Example:

Write a program to display the text “ HAPPY


MOTHERS DAY” 10 times.

Cls
Let x=1
Do while (x<=10)
print “ Happy Mothers
Day”
x=x+1
loop
Write a program to display the sum of all
numbers present between 1 TO 50.

CLS
X=1
Sum=0;
Do while (x<50)
SUM =SUM +x
x=x+1
loop
END
Hands On:
Q1: what is the step value Q1 Answer
of the given source code? The step value is
1(default)
CLS
FOR A = 1 TO 10
PRINT “MUNNA”
NEXT A

Q2: How many times the Q2 Answer


loops will execute? The loop will execute only
one time because the
Cls start value and end value
For a = 10 to 10 step 5 are same
Print “Aditya”
Next a
END
Hands On:
Q3: How many times the
loops will execute?

CLS
A=1
Do while (A <10 )
PRINT “MUNNA”
loop

Q3 Answer
The loop will execute
infinite time because the
start value and end value
are same
Assessment
Time:5 Min
FM=5
Click Here to get question
HOME WORK
WRITE A PROGRAM TO FIND THE SUM OF
FOLLOWING EXPRESSION USING FOR... NEXT AND
DO WHIL E LOOP.

You might also like