Class 7 : Answers to QBasic Exercise programs on Pg. 102

A. 1)
rem to print squares of even numbers from 1 to 20 in reverse order
for i= 20 to 1 step -2
print i ; “*”; i ; ” = ” ; i * i
next i
end

2)
rem to print the first 10 multiples of 6,7,8
for i=6 to 8
for j=1 to 10
print i ; ” * “; j ; “= ” ; i * j
next j
print “=========================”
next i
end

3)
rem to print the series 1,4,9…upto 10 terms
for i= 1 to 10
print i^2
next i
end

4)
rem to print your school name endlessly
i=1
while(i<2)
print “SJPS”
wend
end

5)
REM to print the sum of first 50 odd numbers
sum = 0
n = 1
DO UNTIL n >= 50
sum = sum + n
n = n + 2
LOOP
PRINT sum
END

B.
1)
REM to check whether a number is prime or not
INPUT “enter a number”; n
FOR i = 2 TO n – 1
IF ((n MOD i) = 0) THEN GOTO 100
NEXT i
PRINT “The given no. is prime”
90 GOTO 120
100 PRINT ” The given no. is not prime”
120 END

Leave a comment