GW-Basic

What is GW-Basic?

GW-Basic

GW-Basic stands for Gee-Whiz Beginners’ All-Purpose Symbolic Instruction Code and Graphics and Windows Beginner’s All-Purpose Symbolic Instruction Code.

It is a fundamental  Computer programming language for beginners who want to become an expert computer programmer.


How to Open GW-Basic?

Click on the Start, type gwbasic or basic, if GW-Basic will already be installed then click on it otherwise install it.


How to type programme in GW-Basic?

There are two methods to type programme in GW-Basic.

  1. Direct Method
  2. Indirect Method

Direct Method in GW-Basic

In the direct method, we type the programme without line numbers and get the result just after pressing the enter key.

For example

PRINT 34+45 [Enter]
79
OK


Indirect Method in GW-Basic

In the indirect method, we type the programme with line numbers and get the result after executing the programme by using RUN command or pressing the F2 key

For example

10 PRINT 34+45 [Enter]

RUN [Enter] or F2
79
OK


First Programme in GW-Basic

10 PRINT “Rana Mehtab Alam” [Enter]
20 END

RUN [Enter] or F2
Rana Mehtab Alam
OK


List of  GW-Basic commands and statements with examples.

PRINT
CLS
GOTO
IF THEN ELSE
FOR NEXT
FOR NEXT STEP
READ DATA
LOCATE
LEN
VARIABLES
Use of : ; , 
GW-BASIC GRAPHICS
Shop Billing Software in GW-Basic using DIM
Digital Clock in GW-Basic
Result Sheet
FILES
NEW
SAVE
LOAD


PRINT

To get the output in GW-Basic

PRINT “Rana”

10 PRINT “Rana”

List 


CLS

Clear the Screen

Use this command at the start line of the programme to get the output after clearing the screen.

10 CLS

List 


GOTO

to go to the specific line number

10 CLS
20 PRINT “Rana Mehab Alam”
30 GOTO 20

after executing the above computer programme computer will type Rana Mehtab Alam continuously till you stop it by pressing Ctrl + Pause Break

List 


IF THEN ELSE

to set the conditions in the programme.

10 CLS
20 LET N = 0
30 LET N=N+1
40 PRINT N
50 IF N<10 THEN GOTO 30 ELSE GOTO 60
60 END

after executing the above programme computer will display 1 to 10 numbers in this way.

RUN
1
2
3
4
5
6
7
8
9
10
OK

List 


FOR NEXT

is a loop in GW-Basic

10 FOR K = 1 TO 5
20 PRINT K
30 NEXT K
40 END
RUN
1
2
3
4
5

List 


FOR NEXT with STEP

10 FOR K = 1 TO 10 STEP 2
20 PRINT K
30 NEXT K
40 END
RUN
1
3
5
7
9
OK

List 


READ DATA

read the data from data and generate the output.

10 READ A,B
20 T=A+B
30 PRINT A;”+”;B;”=”;T
40 END
50 DATA 9,8
RUN
9 + 8 = 17

List 


LOCATE

to type at the specific location on the screen.

There are 40 columns and 24 rows in SCREEN 1 and 80 columns and 24 rows in SCREEN 2 : SCREEN 0

If I want to type Rana Mehtab Alam in the center of the screen in SCREEN 2: SCREEN 0: of GW-Basic language programme.

10 CLS
20 LOCATE 32,12 : PRINT”Rana Mehtab Alam”
30 END

List 


LEN

is to use to count the number of characters in word or sentence.

?LEN(“Rana Mehtab Alam”
16

Note: In GW-Basic language we can use ? instead of a PRINT statement.

List 


VARIABLES

Variables play a very important role in making a computer programme in any computer language.

Types of variables in GW-Basic

String Variable

to stores the alphabetic or non-numeric characters in a variable.

LET N$=”Rana Mehtab Alam”

Numeric Variable

to stores the numeric values in the variable.

LET N=9

List 


Use of : ; , 

use of : in GW-Basic

to type two or more than two statements in a single line of GW-Basic input programme.

For example

10 CLS
20 LET A= 0
30 LET B=0

We can type upper lines in a single line using :

10 CLS : LET A= 0 : LET B=0

use of , in GW-Basic

By using (,) in the input programme we can get output in columns.

use of ; in GW-Basic

By using (;) in the input programme we can get output in row.

List 


GW-BASIC GRAPHICS

First, change the screen in SCREEN 1 in GW-Basic, then you can draw lines, circles.

CIRCLE (column,row),radius

In SCREEN 1 total number of columns, 320 and rows  200 for drawing in GW-Basic.

To draw a circle in the middle of the screen with 50 radius

10 CLS : SCREEN 1
20 CIRCLE (160,100),50
RUN

CIRCLE IN GW-BASIC

LINE (START COL,START ROW)-(END COL,END ROW)

10 LINE(10,30)-(40,50)

List 


Shop Billing Software in GW-Basic

10 CLS
20 DIM Q,R,A
30 INPUT “Item
30 INPUT “Item”;I$(S)
40 INPUT “Rate”;R(S)
50 INPUT “Quantity”;Q(S)
60 A(S)=R(S)*Q(S)
62 SUM=SUM+A(S)
70 INPUT”More”;M$
80 IF M$=”y” THEN GOTO 85 ELSE GOTO 90
85 LET S=S+1:GOTO 30
90 CLS
96 PRINT”S/No”,”Item Name”,”Quantity”,”Rate”,”Amount”
100 FOR K=0 TO S
120 PRINT K+1,I$(K),Q(K),R(K),A(K)
130 NEXT K
140 PRINT:PRINT “Total Bill =”,,SUM
150 INPUT”Paid by customer “,PBC
160 LET BAL =SUM-PBC
170 PRINT “Balance =”,,BAL
180 IF BAL<0 THEN G$=”Change return to customer”:GOTO 300
190 IF BAL>0 THEN G$=”Bill is pending from customer”:GOTO 300
200 G$=”Bill Paid Successfuly”
300 PRINT G$
Ok

List 


Digital Clock in GW-Basic

10 REM Programmed by Rana Mehtab Alam.
20 REM if you have any problem contac to 03004467226
30 CLS
40 INPUT “Enter Current hours”;H
50 INPUT “Enter Current minutes”;M
60 INPUT “Enter Current seconds”;S
70 CLS
80 LOCATE 8,10 :PRINT”Lunar Digital Clock”
90 LOCATE 9,10 :PRINT”*=*=*=*=*=*=*=*=*=*”
100 LOCATE 10,14:PRINT”HR : MN : SC”
120 LOCATE 11,18:PRINT M
130 LOCATE 11,23:PRINT S
140 LOCATE 12,10 :PRINT”*=*=*=*=*=*=*=*=*=*”
150 LET S=S+1
160 FOR T = 1 TO 25000!:NEXT T
170 IF S<60 THEN GOTO 110 ELSE GOTO 180
180 LET S=0:LET M=M+1
190 IF M<60 THEN GOTO 110 ELSE GOTO 200
200 LET S = 0 : LET M = 0 :LET H=H+1
210 IF H<12 THEN GOTO 110 ELSE GOTO 220
220 LET S=0:LET M=0:LET H = 1
230 GOTO 110
240 REM Programmed by Rana Mehtab Alam.
250 REM if you have any problem contact to 03004467226
260 END
Ok

List 


Result Sheet Programme in GW-Basic

10 CLS
20 INPUT “Student Name”;SN$
30 INPUT “Class”;CL$
40 CLS
50 INPUT “Total Marks in English”;ENG
60 INPUT “Obtain Marks in English”;E
70 INPUT “Total Marks in Maths”;MTH
80 INPUT “Obtain Marks in Maths”;M
90 INPUT “Total Marks in Urdu”;UR
100 INPUT “Obtain Marks in Urdu”;U
120 INPUT “Obtain Marks in Physics”;P
130 INPUT “Total Marks in Chemistry”;CHE
140 INPUT “Obtain Marks in Chemistry”;C
150 LET ST = ENG+MTH+UR+PHY+CHE
160 LET OT=E+M+U+P+C
170 LET A=OT/ST*100
180 IF A>=80 AND A<=100 THEN G$=”A+”:GOTO 250
190 IF A>=70 AND A<80 THEN G$=”A”:GOTO 250
200 IF A>=60 AND A<70 THEN G$=”B”:GOTO 250
210 IF A>=50 AND A<60 THEN G$=”C”:GOTO 250
220 IF A>=40 AND A<50 THEN G$=”D”:GOTO 250
230 IF A>=33 AND A<40 THEN G$=”E”:GOTO 250
240 LET G$=”Fail”
250 IF G$=”A+” THEN R$=”Most Excellent” :GOTO 320
260 IF G$=”A” THEN R$=”Excellent”:GOTO 320
270 IF G$=”B” THEN R$=”Very Good”:GOTO 320
280 IF G$=”C” THEN R$=”Good”:GOTO 320
290 IF G$=”D” THEN R$=”Nice”:GOTO 320
300 IF G$=”E” THEN R$=”Average”:GOTO 320
310 LET G$=”Bad”
320 CLS
325 PRINT “Name”,n$
327 PRINT “Class”,cl$
330 PRINT “Subject”,”Total”,”Obtained”
340 PRINT “English”,ENG,E
350 PRINT “Math”,MTH,M
360 PRINT “Urdu”,UH,U
370 PRINT “Physics”,PHY,P
380 PRINT “Chemistry”,CHE,C
390 PRINT “Avg Marks =”;A
400 PRINT “Grades =”;G$
410 PRINT “Remarks=”;R$
420 END

List 


Table Learning Software in GW-Basic

10 CLS
20 INPUT “WHICH TABLE DO YOU WANT”;T
30 INPUT “WHERE TO START”;S
40 INPUT “WHERE TO END”;E
45 CLS
50 PRINT “TABLE OF”;T
60 PRINT “—————”
70 PRINT T;”X”;S;”=”;T*S
80 S=S+1
90 IF S<=E THEN GOTO 70 ELSE GOTO 100
100 PRINT “—————”
120 INPUT “DO YOU WANT MORE TABLES…Y/N”;T$
130 IF T$=”Y” OR T$=”YES” OR T$=”yes” OR T$=”Yes” OR T$=”y” THEN GOTO 10 ELSE GOTO 140
140 PRINT “THANKS”
150 END

List 


FILES

call the list files and directories.

List 


NEW

to erase the programme from the computer’s memory

List 


SAVE

to save the current programme

SAVE”FileName

F4 for Save

Note: Maximum 8 characters for save file name in GW-Basic witout spacing.

List 


LOAD

to load the saved programme

LOAD”FileName

F3 for Load

List 


      Home      Courses      

Spread the love
Rana Mehtab Alam Lunar Computer College.