Page |1
Shahwilayat public school
Campus 1
Computer portfolio
2018-2019
Submitted By
MOHAMMAD IRTIZA
Page |2
Practical 1 a
Objective: Write a program to print your name 10 times using FOR NEXT
LOOP.
Code:
10 Read A$
20 For k=1 to 10
30 print A$
40 next K
50 data IRTIZA
60 end
Practical 1 b
Objective: Write a program to print your name 10 times WHILE WEND LOOP.
Code:
10 Input “enter your name”;A$
20 let A=1
30 while A<=10
40 print A$
50 A=A+1
60 WEND
70 end
Page |3
Practical 1 a
Output
Practical 1 b
Output
Page |4
Practical 1 a
Flowchart
Practical 1 b
Flowchart
Page |5
Practical 2 a
Objective: Convert Temperature from Celcius to Farenheit.
Code:
10 Input “Enter temperature in Celcius”;C
20 F=5/9*(C+32)
30 print ;C;”celcius is equals to:”;F;”Fraenheit”
40 END
Practical 2 b
Objective: Convert Temperature from Farenheit to Celcius.
Code:
10 input “enter temperature in farenheit”;F
20 C=5/9*(F-32)
30 print ;F;”farenheit is equals to:”;C;”Farenheit”
40 end
Page |6
Practical 2 a
Output
Practical 2 b
Output
Page |7
Practical 2 a
Flowchart
Practical 2 b
Flowchart
Page |8
Practical 3
Objective: write a program to generate the table using LET and GOTO statement.
Code:
10 input “enter a number”;M
20 let n=1
30 n=n+1
40 p=M*N
50 print M,N,P
60 if n>=11 then goto 80 else 70
70 goto 30
80 end
Page |9
Practical 3
Output
P a g e | 10
Practical 3
flowchart
P a g e | 11
Practical 4
Objective: write a program to find by the greatest number from three number
input by user .
Code:
10 Input “enter first number”;N1
20 Input “enter second number”;N2
30 Input “enter third number”;N3
40 if N1>N2 and N1>N3 then print “N1 is greatest”
50 if N2>N1 and N2>N3 then print “N2 is greatest”
60 if N3>N1 and N3>N2 then print “N3 is greatest”
70 END
P a g e | 12
Practical 4
Output
P a g e | 13
Practical 4
Flowchart
P a g e | 14
Practical 5
Objective: calculate the income TAX from salary input by user.
Code:
10 cls
20 Input “Enter Salary”;S
30 TAX=(5/100)*S
40 NET=S-TAX
50 print “Your salary is= “;S
60 print “Your TAX is= “;TAX
70 print “Your NET salary is= “;NET
80 END
P a g e | 15
Practical 5
Output
P a g e | 16
Practical 5
Flowchart
P a g e | 17
Practical 6 a
Objective : write a program to find the area of circle (area=3.14*R^2)
Code:
10 Input “Radius of a circle”;R
20 let p=3.14
30 let area=p*(R^2)
40 print “Area of a circle= “;area
50 end
Practical 6 b
Objective: write a program to find the volume of cylinder (V=3.14*R^2*H)
Code:
10 input “radius of a cylinder”;R
20 input “height of cylinder”;h
30 let C=3.14*(R^2)*h
40 print “Volume of a cylinder= “;C
50 end
Practical 6 c
Objective: write a program to find the area of triangle (A=0.5*B*H)
Code:
10 input “breadth of a triangle”;B
20 input “height of a triangle”;h
30 area=0.5*B*h
40 print “Area of a triangle= “;area
P a g e | 18
Practical 6 a
Output
Practical 6 b
Output
P a g e | 19
Practical 6 c
Output
P a g e | 20
Practical 6 a
Flowchart
Practical 6 b
Flowchart
P a g e | 21
Practical 6 c
Flowchart
P a g e | 22
Practical 7
Objective: write a program to prepare an electricity bill.
Code:
10 cls
20 input “current reading”;CR
30 input “previous reading”;PR
40 Let NR=CR-PR
50 Let BA=NR*15.90
60 print “Current reading= “;CR
70 print “Previous reading= “;PR
80 print “NEW READING= “;NR
90 print “BILL amount = “;BA
100 end
P a g e | 23
Practical 7
Output
P a g e | 24
Practical 7
Flowchart
P a g e | 25
Practical 8
Objective: write a program to prepare a Mark Sheets of five subjects.
Code:
10 input “Enter name”;N$
20 input “enter class”;C$
30 print “enter marks in following subjects out of 100”
40 input “math”;M
50 input “computer”;C
60 input “PST”;P
70 input “islamiat”;I
80 input “Science”;S
90 print “Student Name: “;N$
100 print “Class: “;C$
110 print “Marks in maths= “;M
120 print “Marks in Computer= “;C
130 print “Marks in PST= “;P
140 print “Marks in islamiat= “;I
150 print “Mraks in Science= “;S
160 Totalmarks= M+C+P+I+S
170 PERCENTAGE=(Totalmarks*100)/500
180 print “Total Marks= “;Totalmarks
190 print “Percentage= “;PERCENTAGE
200 end
P a g e | 26
Practical 8
Output
P a g e | 27
Practical 8
Flowchart
P a g e | 28
Practical 9
Objective: write a program to calculate the salary with bonus of 20 employees
using IF THEN statement and FOR NEXT LOOP.
Code:
10 cls
20 For C=1 to 20
30 print C
40 Input “Enter Salary”;SAL
50 if SAL<50000 then Bonus=5000 else Bonus=3000
60 let SAL=SAL+Bonus
70 print TAB(30);”The net salary is= “;SAL
80 print
90 next C
100 end
P a g e | 29
Practical 9
Output
P a g e | 30
Practical 9
Flowchart
P a g e | 31
Practical 10a
Objective: write a program to generate sequence 2,4,6,……..99 using IF THEN
ELSE and GOTO statement.
Code:
10 cls
20 let A=0
30 let A=A+2
40 if A>99 then goto 70
50 print A
60 goto 30
70 end
Practical 10b
Objective: write a program to generate odd numbers from 13 to 250 using IF
THEN and GOTO statement.
Code:
10 cls
20 let A=11
30 Let A=A+2
40 if A>250 then goto 70
50 print A
60 goto 30
70 end
P a g e | 32
Practical 10a
Output
Practical 10b
Output
P a g e | 33
Practical 10a
Flowchart
Practical 10b
Flowchart
P a g e | 34
Practical 11
Objective: Write a program to print the square and cube of first ten natural
numbers.
Code:
10 cls
20 Print “NUMBER”.”SQUARE”,”CUBE”
30 For N=1 to 10
40 Print N,N^2,N^3
50 Next N
60 end
P a g e | 35
Practical 11
Output
P a g e | 36
Practical 11
Flowchart
P a g e | 37
Practical 12
Objective: write a program to generate the pattern using Nested loop.
Code:
10 For x=1 to 5
20 for y= 1 to x
30 print “*”;
40 next y
50 print
60 next x
70 end
P a g e | 38
Program 12
Output
P a g e | 39
Practical 12
Flowchart
P a g e | 40
Practical 13
Objective: write a program to find the biggest number from an array.
Code:
10 cls
20 DIM L(20)
30 For A=1 to 10
40 input “enter a number”;L(A)
50 Next A
60 Let BIG=L(1)
70 For A=2 to 10
80 if BIG<L(A) then BIG=L(A)
90 Next A
100 print “The biggest number is: “;BIG
110 END
P a g e | 41
Practical 13
Output
P a g e | 42
Practical 13
Flowchart
P a g e | 43
Practical 14
Objective: write a program to save and print an age of 20 people using an
ARRAY
Code:
10 cls
20 DIM AGE(20)
30 for k=1 to 20
40 print k
50 input “Give Age”;AGE(K)
60 next K
70 print “The ages are: “
80 print
90 for k= 1 to 20
100 print “………”
110 next k
120 for k=1 to 20
130 print K,AGE(K)
140 next K
150 end
P a g e | 44
Practical 14
Output
P a g e | 45
Practical 14
Flowchart
P a g e | 46
Practical 15
Objective: write a program to find the total number of Male and Female students
from an ARRAY.
Code:
10 cls
20 for A=1 to 10
30 input “enter name”;N$(A)
40 input “enter gender”;G$(A)
50 next A
60 print “[Link]”,”NAME”,”GENDER”
70 for B=1 to 10
80 let M=0 : f=0
90 print B,N$(A),G$(A)
100 if left$(G$(B),10)=”F” then F=F+1 else M=M+1
110 next B
120 print “total no of male students= “;M
130 print “total no of female students= “;F
140 end
P a g e | 47
Practical 15
Output
P a g e | 48
Practical 15
Flowchart
P a g e | 49
Practical 16a
Objective: program to print the numbers from an ARRAY in Ascending order.
Code:
10 DIM N(20)
20 for I=1 to 20
30 input “enter a number”;N(I)
40 next I
50 for I=1 to 19
60 for J=(I+1) to 20
70 if N(I)>N(J) then SWAP N(I),N(J)
80 NEXT J
90 Next I
100 for I=1 to 20
110 print “Sorted(Ascending)”;N(I)
120 next I
130 end
P a g e | 50
Practical 16b
Objective: program to print the numbers from an ARRAY in Descending order
Code:
10 cls
20 DIM N(20)
30 for I=1 to 20
40 input “enter a number”;N(I)
50 next I
60 for I=1 to 19
70 for J=(I+1) to 20
80 if N(I)<N(J) then SWAP N(I),N(J)
90 next J
100 next I
110 for I=1 to 20
120 print “Sorted(Descending)”;N(I)
130 next I
140 end
P a g e | 51
Practical 16a
Output
Practical 16b
Output
P a g e | 52
Practical 16a
Flowchart
Practical 16b
flowchart
P a g e | 53
Practical 17a
Objective: write a program to draw a Triangle.
Code:
10 cls
20 screen 2
30 Draw “G50 R100 H50”
40 end
Practical 17b
Objective: write a program to draw a rectangle.
Code:
10 cls
20 screen 2
30 draw “D60 R50 U60 L50”
40 end
P a g e | 54
Practical 17a
Output
Practical 17b
Output
P a g e | 55
Practical 17a
Flowchart
Practical 17b
Flowchart
P a g e | 56
Practical 18a
Objective: write a program to draw a circle.
Code:
10 cls
20 screen 2
30 circle (100,100),50
40 end
Practical 18b
Objective: write a program to draw a square in a square.
Code:
10 cls
20 line (50,50)-(110,110),1,B
30 line (55,55)-(105,105),1,B
40 end
P a g e | 57
Practical 18a
Output
Practical 18
Output
P a g e | 58
Practical 18a
Flowchart
Practical 18b
Flowchart
P a g e | 59
Practical 19
Objective: write a program to draw an Olympic Circle.
Code:
10 cls
20 screen 9
30 circle (130,75),35,4
40 circle (185,75),35,8
50 circle (225,75,35,1
60 circle (210,95),35,14
70 circle (150,95),35,2
80 end
P a g e | 60
Practical 19
Output
P a g e | 61
Practical 19
Flowchart
P a g e | 62
Practical 20a
Objective: write a program to construct a regular Hexagon.
Code:
10 cls
20 screen 1
30 draw “E30 R50 F30 G30 L50 H30”
40 end
Practical 20b
Objective: write a program to construct a regular Octagon.
Code:
10 cls
20 screen 2
30 draw “E20 R30 F20 D25 G20 L30 H20 U25”
40 end
P a g e | 63
Practical 20a
Output
Practical 20b
Output
P a g e | 64
Practical 20a
Flowchart
Practical 20b
Flowchart
P a g e | 65
Practical 21a
Objective: write a program to generate a Random Number between 0 to 1 using
RND function.
Code:
10 for x=0 to 3
20 for k=1 to 6
30 print rnd(x)
40 next k
50 next x
60 end
Practical 21b
Objective: write a program to truncate an integer using FIX function.
Code:
10 print fix (39-59)
20 print fix (-10.55)
30 end
P a g e | 66
Practical 21a
Output
Practical 21b
Output
P a g e | 67
Practical 21a
Flowchart
Practical 21b
Flowchart
P a g e | 68
Practical 22
Objective: write a program to implement GOSUB and Return statement in a sub
routine program.
Code:
10 for j=1 to 4
20 go sub 50
30 next j
40 end
50 300 let p=j*j+5*j
60 return
70 print j, p
80 print “correct”
90 end
P a g e | 69
Practical 22
Output
P a g e | 70
Practical 22
Flowchart
P a g e | 71
Practical 23
Objective: write a program to define the user define Function in order to find the
Hypotenuse of a right angled triangle.
Code:
10 def fnhypot (a,b)=SQR(a^2+b^2
20 print “enter two sides”
30 input s1,s2
40 print “the hypotenuse=”;fnhypot (s1,s2)
50 end
P a g e | 72
Practical 23
Output
P a g e | 73
Practical 23
Flowchart