Class 7 : Answers to QBasic Exercise Programs on Pg.93

A) i) Generate Series 11,22,33 …. upto 10 terms
10 let n=11
20 if n<=110 then goto 30 else goto 60
30 print n
40 n=n+11
50 goto 20
60 end

ii) Generate series 2,9,28,65 … upto 10 terms
10 let n=1
20 if n<=10 then goto 30 else goto 60
30 print n^3 +1
40 n=n+1
50 goto 20
60 end

B) Write programs to display characters in the given format :
i)
10 let n=1
20 let r=1
30 if n<=5 then goto 40 else goto 80
40 print r,r+1,r+2,r+3,r+4
50 r=r+1
60 n=n+1
70 goto 30
80 end

ii)
screen 12
color 2,15
cls
let a$=”@”
print a$,a$,a$,a$,a$
print a$,a$,a$,a$
print a$,a$,a$
print a$,a$
print a$
end

iii)
screen 12
color 12,15
cls
a$=”$”
print tab(15);a$
print tab(10);a$;tab(15);a$;tab(20);a$
print tab(5);a$;tab(10);a$;tab(15);a$;tab(20);a$;tab(25);a$
print tab(10);a$;tab(15);a$;tab(20);a$
print tab(15);a$
end

C)
1) sum of squares of odd numbers upto 10 terms
10 let n=1
20 let sum=0
30 if n<=10 then goto 40 else goto 70
40 sum=sum+n^2
50 n=n+2
60 goto 30
70 print sum
80 end

2) draw a square of size 100 x 100 pixels at the center of the screen and fill with blue color.
screen 12
color 1,14
cls
line(270,190) – (370,290),1,bf
end

3) draw an equilateral triangle
screen 12
color 1,15
line(280,240)-(360,240),1
line(360,240)-(320,160),1
line(320,160)-(280,240),1
paint(300,220),1
end

4) draw three concentric circles with equal distance between them.
screen 12
color 1,15
cls
circle(320,240),30,1
circle(320,240),60,1
circle(320,240),90,1

Lab Activity QBasic Programs :

(i)Smiley face :

SCREEN 12
CIRCLE (320, 240), 70, 5
PAINT (320, 240), 5
CIRCLE (320, 255), 30, 15, 3.3, 6.13
CIRCLE (285, 215), 10, 15
CIRCLE (355, 215), 10, 15
END

(ii) Concentric colour filled circles :

SCREEN 12
CIRCLE (320, 240), 100, 2
PAINT (320, 240), 2
CIRCLE (320, 240), 50, 4
PAINT (320, 240), 4

(iii)Hut shape :

SCREEN 12
LINE (260, 180)-(320, 60), 4
LINE (320, 60)-(380, 180), 4
LINE (380, 180)-(260, 180), 4
PAINT (320, 80), 4
LINE (260, 180)-(380, 300), 9, BF

Leave a comment