_Learn about BASIC
_History of BASIC
_What is GW BASIC
_Rules Of GW BASIC
_All basic use of GW BASIC
_All basic command of GW BASIC
_Coding in GW BASIC
Requirements
Because we are learning about programming in GW BASIC so first we have to learn its rules
Rules of GW BASIC
Each instruction in a GW BASIC program is written as a separate statement Thus, a complete GW BASIC program will composed of a sequence of statement The following rules are suggested for programming in GW BASIC
Each instruction must be started with a line number , which must be an integer such as 10,20,30,40 etc for example
10 LETA = 5
After typing the line number a blank space must be given and only then the instruction should be written For example 10 LETA = 5
After a blank space, the starting of any instruction should be done by the keyword , which is also called command word. A command word tells the computer about the type of function to be done For Example 10 LETA = 5
Keyword must be written using the appropriate syntax .Each keyword has its own syntax , which differs from the other For Example 10 LETA = 5
When the statement is completely typed in , press the Enter key to start the next statement in the next line for example : 10 LETA = 5 (press " " Enter key)
Never use the duplicate line number .This will cause overwriting on the statement on the same line number.For Example: 10 LETA = 5
Note
The line number may be any number between 1-9999
It is better to use line numbers in the order of tens i.e 10, 20, 30 ........This facilitates the addition of any instruction between the two lines
Characters Sets
The Microsoft GW BASIC characters set consist of Alphabetic characters .Numeric characters and Special characters.
Alphabetic characters
The alphabetic characters in GW BASIC are the uppercase letter <A,B,C...................>And lower <a,b,c..................> of the English alphabet. Numeric characters
The GW BASIC numeric characters are the 10 digits from 0 to 9. Special characters
The GW BASIC special characters are below in the image
Elements of BASIC
Elements of BASIC are as follow
Constant
Numerical quantities in BASIC are referred to as numbers or constant .Constant cannot change during program execution.There are two types of constant
Numeric Constant
Example 28,764,42.09,+402,-1300 etc
String Constant
Example "AHMED" , "Karachi" , "A128" , "62-44-452432" , "It is Quick Way To Learn Computer"
Variable
There are two type so of variable
Numeric variable
Example 9, -88, -34, +86 etc
String variable
NAMES$, Pakistan$, Lahore$, Th88$
Operators
Operations are lexical entity that indicates the action to be performed on operands(constant and variable). Operators perform mathematical or logical operations on value There are three type of operators.
Arithmetic operators
Relational operators
Logical operators
Arithmetic operations
Arithmetic operations perform simple mathematical calculation such as addition and subtraction .All arithmetic operations are listed below in the following table with their implicit order of priority.
Order of Priority
Computer assigns an order of priority to operators by which high priority operators are evaluated before those low priority .Operators of equal priority are performed from left to right
Example 1: 8/22/2+412
Example 2: 4+9/3-1
Its will solved step by step as shown in this link codes https://github.com/HelpToGrow/RanaTalhaTraiq/blob/master/Examples%20GW%20BASIC
Relational Operators
Relational Operators are used to make a decision in theexecution of program . They compare two values and result will be either True or False The relational operators are given in the following table.
Logical Operators
In GW BASIC, there are three logical operators:
AND
OR
NOT
logical operators are used to define / redefine decisions
Expression
An expression is collection of operands (constant and variable) to join together certain operations to perform the algebraic like term. Conversion of arithmetic expression into BASIC expressions is in this picture
GW BASIC Functional Words
Functional Words are used in expressions to perform predefined routine on an operands .For example LEN , MID$ ,SQR etc there are two kinds of functional words
Reserved Functional words
User Defined Functional Words
Reserved Functional words
Basic has built in functions that can be used by simple calling them . For example LEN, LEFT$ , SQR etc are reserved functional words . These word cannot be used as variable names. The list of reserved in given below in the image
Syntax,/h3>
Syntax is the rule of language just like grammatical rule for English language .If we do not follow the rules of English Language we cannot write good English .Similar is in GW BASIC language .If we do not now about the rules of BASIC language we cannot write program.
Download any GW BASIC version according to your need and device for coding in GW BASIC
Statement
In GW BASIC language , programs are written in a sequence , which consist of a series of statement .Each statement consists of one or more lines in length and each statement in a program must store with a statement number.
REM Statement
If we want to give any heading or want to type miscellaneous remarks , The REM statement is used . REM is an abbreviated for remarks .This statement facilitates us to type any remarks such as the following.
LET Statement
If we want to give any data to the computer, which is to be used many times in the program, we may assign it in a variable . To assign any single data , we may use LET statement
Syntax
(line number) LET (Variable = data)
Example are in github with Heading ### Example # 3
https://github.com/HelpToGrow/RanaTalhaTraiq/edit/master/Examples%20GW%20BASIC
INPUT Statement
Using INPUT statement , we can input data into the computer .This statement provides the facility to input data
Syntax
The INPUT statement has the following syntax
(line num) INPUT (List of the variable separated by commas)
22 INPUT A, B,
Example is in the github with heading ### Example # 4
PRINT Statement
If we want to display the result on our monitors's screen using the BASIC statement use print statement
Print statement is used as given in the following syntax :
Example
100 PRINT T
110 PRINT AV
120 PRINT , AV
If we want to print on the screen
Any text ,which we want to print on the screen , is written just like the variable but this is enclosed with quotes
Example
130 PRINT "Lahore"
We will write the variable separated by the commas .Thus the values will be printed in the same line on the screen
Read - Data statement
Read - Data statement are two statements connected with each other which are used to put data in a line of a program and to read the date when it needed
Read statement is used as given in the following
Syntax
(Line Number) READ
Example is in the github with heading ### Example # 5
Data Statement
Data Statement has the following syntax
Syntax
(line number) DATA
Example is on github with heading ### Example # 6
Question
Write a program to find the average of the number 27,93,84,60,45 ?
Unconditional Jump in the program
Sometime it is required to jump at a certain step of program unconditionally .Thus certain steps could be repeated or skipped .For this purpose GOTO Statement is used.
GOTO Statement
With the GOTO statement ,that the line number is given on which we want to jump General syntax is as below
Syntax
(line number)GOTO(line number on which we want to go)
50 GOTO 10
Example Is on GitHub with heading ### Example # 7
https://github.com/HelpToGrow/RanaTalhaTraiq/blob/master/Examples%20GW%20BASIC
Question Write a program to generate the number from one to indifinate
Save the Program
To save means to get a program recorded on drive ,If we want to store our program on the hard disk or any recording media we may use Save command.
Introduction to BASIC
Introduction to BASIC is an abbreviation of " Beginners All Purpose Symbolic Instruction Code" BASIC is easy to learn high-level interactive programming language . It is a very simple and similar to English for example : LET, PRINT,GOTO,INPUT,READ,WRITE,IF..THEN etc. Are the some statement Of Basic has become more popular and famous.
BASIC is helpful in all fields of life.We may make programs for different purpose for example Accounting ,Spread sheet ,Business,Science ,Engineering and Education etc . BASIC has also graphic facilities and sound generation system so that we may enjoy BASIC as playing games. History of basic
The early computer languages are little difficult to learn and apply .As the use of computer became more wide spread it was decided that a new simple language was needed , this formed the basis of BASIC.
Dr John G. Kemeny and Dr .Thomas E.Kurtz professor of Dartmount College USA developed a simple language for beginners in mid 1960's The language has some grammatical rules just like as English grammar rules called syntax. Within very short period BASIC was widely used in schools,colleges and many other fields. After development of microcomputer 1970's BASIC became standard language for microcomputer.Now BASIC is not very popular but still it used in schools to teach programming to beginners . Now we are talking about GW BASIC So
What is GW Basic
BASIC got the ANSI (American National Standard Institute) standard in 1978 Different versions of BASIC language introduced but now common version is GW BASIC We had syntax GW BASIC Nearly all BASIC language have same syntax