100% found this document useful (1 vote)
4K views

GW Basic Programs

The document provides instructions for building 10 basic programs in GW BASIC including programs to add, subtract, multiply and divide numbers, calculate speed, area of shapes, percentages and a basic calculator. It explains the purpose and provides the code, inputs and outputs for each program as an educational guide for students learning to code in BASIC.

Uploaded by

Sudhanshu Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views

GW Basic Programs

The document provides instructions for building 10 basic programs in GW BASIC including programs to add, subtract, multiply and divide numbers, calculate speed, area of shapes, percentages and a basic calculator. It explains the purpose and provides the code, inputs and outputs for each program as an educational guide for students learning to code in BASIC.

Uploaded by

Sudhanshu Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Welcome to GW BASIC PROGRAM Page

The program i will made will be commonly asked by teacher to build in classroom by students
EXAMPLE
1)build a program to find a speed of body
2)build a program to find a percentage of students
3)build a calculator
4)build a result card
etc
so without wasting any time we should procedure and we will continue with simple programs
program#1
How to build a program that input two numbers and add them and give result

10 cls
20 input"enter the first number to be add",x
30 input"enter the second number to be add",y
40 z=x+y
50 print x"+"y"="z
60 end

OUTPUT
enter the first number to be add 2
enter the second number to be add 5
2+5=7

program#2
How to build a program that input two numbers and subtract them and give result

10 cls
20 input"enter the first number to be subtract",x
30 input"enter the second number to be subtract",y
40 z=x-y
50 print x"-"y"="z
60 end

OUTPUT
enter the first number to be subtract 3
enter the second number to be subtract 2
3-2=1

program#3
How to build a program that input two numbers and multiply them and give result
10 cls
20 input"enter the first number to be multiply",x
30 input"enter the second number to be multiply",y
40 z=x*y
50 print x"*"y"="z
60 end

OUTPUT
enter the first number to be multiply 2
enter the second number to be multiply 2
2*2=4

program#4
How to build a program that input two numbers and divide them and give result

10 cls
20 input"enter the first number to be divide",x
30 input"enter the second number to be divide",y
40 z=x/y
50 print x"/"y"="z
60 end

OUTPUT
enter the first number to be divide 2
enter the second number to be divide 2
2/2/=1

program#5
How to build a program that show a table of any number

10 cls
20 input"enter he number whose table you wanted to see",x
30 for y=1 to 10
40 z=x*y
50 print x"*"y"="z
60 next
70 end

OUTPUT
enter he number whose table you wanted to see 2
the table of 2 will appear

program#6
How to build a program that calculate the speed of body by using velocity and time for these kinds
of programs you should know the basic formulas and for this is "speed=velocity*time"

10 cls
20 input"enter the value of velocity",x
30 input"enter the value of time in second",y
40 s=x*y
50 print"the speed of body="s"m/s"
60 end

OUTPUT
enter the value of velocity 2
enter the value of time in second 2
the speed of body=4 m/s

program#7
How to build a program that calculate the area of circle and the formula is lets consider A=3.14 so
A=AR^2

10 input"enter the value of radius",x


20 e=3.1415
30 z=e*x^2
40 print"the area of circle="z
50 end

OUTPUT
enter the value of radius 3
the area of circle=28.26

program#8
How to build a program that calculate the area of triangle and formula is A=1/2*b*h

10 cls
20 input"",x
30 input"enter the value of vertical height",y
40 a=1/2*x*y
50 print"the area of triangle="a
60 end

OUTPUT
enter the value of base 2
enter the value of vertical height 2
the area of triangle=2
program#9
How to build a program that calculate the area of square and formula is A=a^2

10 cls
20 input"enter the length of any side of square",x
30 z=x*x
40 print"the area of square="z
50 end

OUTPUT
enter the length of any side of square 2
the area of square=2

program#10
How to build a program that calculate the area cylinder formula is A=pie*r^2*h

10 cls
20 input"enter the value of height of cylinder",x
30 input"enter the value of radius of cylinder",y
40 z=3.14*y^2*x
50 print"the volume of cylinder="z
60 end

OUTPUT
enter the value of height of cylinder 2
enter the value of radius of cylinder 2
the volume of cylinder=25.12

Now we will move to our last 3 very important program

program#11
How to build a program that calculate percentage of numbers

10 cls
20 input"enter the total number",x
30 input"enter number you got",y
40 z=y/x
50 c=z*100
60 print"the percent="c
70 end

OUTPUT
enter the total number 100
enter number you got 50
the percent=50

program#12
How to build a program that show that grads of students

10 cls
20 input"enter the total numbers",x
30 input"enter the child number",y
40 z=y/x
50 c=z*100
60 if c>=80 goto 120
70 if c>=70 goto 140
80 if c>=60 goto 160
90 if c>=50 goto 180
100 if c>=40 goto 200
110 if c<40 goto 220
120 print"grade A+1"
130 end
140 print"grade A"
150 end
160 print"grade B"
170 end
180 print"grade C"
190 end
200 print"grade D"
210 end
220 print"grade f"
230 end

OUTPUT
enter the total numbers 100
enter the child number 90
grade A+1
program#13
How to make a calculator this calculator can add,multiply and divide

10 cls
20 input"enter first number",x
30 input"enter second number',y
50 print"1 for *"
60 print"2 for /"
70 print"3 for + "
75 input"select any one from above",c
80 if c=1 goto 120
90 if c=2 goto 150
100 if c=3 goto 180 else goto 110
110 print"wrong input the program is terminated"
115 end
120 z=x*y
130 print x"*"y"="z
140 end
150 z=x/y
160 print x"/"y"='z
170 end
180 z=x+y
190 print x"+"y"="z
200 end

OUTPUT
output is very long

You might also like