BASIC PROGRAMMING LANGUAGE
Meaning of BASIC
BASIC is an acronym for Beginner’s All-purpose Symbolic Instruction Code.
It is a high-level programming language that was designed to help beginners learn how to write computer programs easily.
BASIC was developed in 1964 by John Kemeny and Thomas Kurtz at Dartmouth College in the United States of America.
Meaning of a Programming Language
A programming language is a set of instructions and rules used to communicate with a computer.
It allows the user to write commands that tell the computer what to do.
A program is a set of instructions written in a programming language to perform a specific task.
Types of Programming Languages
Programming languages are generally divided into two main types:
- Low-Level Languages
These are languages that are close to the machine’s language (binary or assembly).
They are difficult for humans to understand but easy for computers to execute.
Examples:
- Machine language
- Assembly language
- High-Level Languages
These are languages that are close to human languages.
They are easier to learn and understand.
Examples:
- BASIC
- FORTRAN
- COBOL
- C
- Python
- Java
History of BASIC
BASIC was created in 1964 at Dartmouth College.
It was designed to make programming simple for students who were not science majors.
Over time, many versions of BASIC have been developed, such as:
- GW-BASIC
- QBasic
- Visual BASIC
Features of BASIC Programming Language
- It is easy to learn and use, especially for beginners.
- It uses simple English-like commands.
- It is a high-level language.
- It allows interactive programming (the user can type and run commands directly).
- It can run on many types of computers.
- It supports mathematical and logical operations.
- Programs written in BASIC are readable and understandable.
Uses of BASIC Programming Language
- It helps you to learn the logic of programming.
- It helps you to develop small applications.
- It helps you to perform mathematical calculations.
- It helps you to understand how computers process instructions.
- It is used in teaching computer programming concepts in schools.
BASIC Character Set
The character set of BASIC refers to all the symbols, letters, and digits that can be used when writing BASIC programs.
The BASIC character set includes the following:
- Alphabets: All uppercase (A–Z) and lowercase (a–z) English letters.
- Digits: The numbers 0–9 used to represent numeric values.
- Special Characters: Symbols such as +, -, *, /, =, <, >, (, ), ;, :, " " and others used for operations and punctuation.
- White Spaces: Spaces, tabs, and blank lines used to separate words or improve readability.
- Reserved Words (Keywords): Special words that have predefined meanings in BASIC, such as PRINT, INPUT, LET, IF, THEN, FOR, NEXT, GOTO, REM, and END.
- Strings: A sequence of characters enclosed in quotation marks, for example "HELLO" or "SUM = ".
- Operators: Symbols used for performing operations, such as:
Arithmetic Operators: +, -, *, /
Relational Operators: =, <, >, <=, >=, <> (not equal)
Logical Operators: AND, OR, NOT
Structure of a BASIC Program
A BASIC program is made up of lines of statements.
Each line usually begins with a line number followed by an instruction (statement).
For example:
10 INPUT A
20 INPUT B
30 LET C = A + B
40 PRINT C
50 END
Explanation:
- Line 10: Asks the user to input the first number.
- Line 20: Asks the user to input the second number.
- Line 30: Adds the two numbers and stores the result in C.
- Line 40: Displays the result.
- Line 50: Ends the program.
Common BASIC Statements/Commands and Their Functions
Statements in BASIC are the instructions that tell the computer what to do. Every BASIC program is made up of one or more statements written in a specific order. Each statement normally starts with a line number.
| Command | Meaning / Function |
| REM | Used to write remarks or comments in a program. Example: 10 REM This program adds two numbers |
| INPUT | Used to accept data from the user. Example: 20 INPUT A |
| LET | Used to assign a value to a variable. Example: 30 LET C = A + B |
| PRINT | Used to display results on the screen. Example: 40 PRINT C |
| END | Marks the end of the program. Example: 50 END |
| IF...THEN | Used for decision making. Example: 60 IF A > B THEN PRINT "A is greater" |
| FOR...NEXT | Used for loops (repeating actions). Example: FOR I = 1 TO 10: PRINT I: NEXT I |
| GOTO | Used to jump to another line in the program. Example: 70 GOTO 20 |
Rules for Writing BASIC Programs
- Each statement usually begins with a line number.
- Line numbers should increase in order (for example: 10, 20, 30...).
- The program should begin with INPUT statements (if needed).
- The program should end with an END statement.
- Use LET to perform assignments.
- Use PRINT to display results.
- Use REM for comments to explain what each part of the program does.
Example Program 1: Addition of Two Numbers
10 REM Addition of two numbers
20 INPUT A
30 INPUT B
40 LET C = A + B
50 PRINT "The sum is "; C
60 END
Explanation: The program accepts two numbers and prints their sum.
Example Program 2: Finding the Area of a Rectangle
10 REM Area of a rectangle
20 INPUT L
30 INPUT B
40 LET A = L * B
50 PRINT "Area = "; A
60 END
Example Program 3: Finding the Average of Three Numbers
10 REM Average of three numbers
20 INPUT A
30 INPUT B
40 INPUT C
50 LET SUM = A + B + C
60 LET AVG = SUM / 3
70 PRINT "Average = "; AVG
80 END
Example Program 4: Checking if a Number is Positive or Negative
10 REM Check positive or negative
20 INPUT N
30 IF N > 0 THEN PRINT "Positive"
40 IF N < 0 THEN PRINT "Negative"
50 IF N = 0 THEN PRINT "Zero"
60 END
Advantages of BASIC Programming Language
- It is very simple and easy to learn.
- It uses English-like words.
- It allows immediate testing of programs.
- It helps beginners understand programming easily.
- It runs on many different computer systems.
Disadvantages of BASIC Programming Language
- It is slow in execution compared to modern languages.
- It is not suitable for complex programs.
- It is an old language and not widely used for modern applications.
- It requires more lines of code to perform simple tasks.
Versions of BASIC
- Dartmouth BASIC (original version)
- GW-BASIC
- QBasic
- Visual BASIC (VB)
- FreeBASIC
Summary
- BASIC stands for Beginner’s All-purpose Symbolic Instruction Code.
- It is a high-level programming language.
- It was developed by John Kemeny and Thomas Kurtz in 1964.
- BASIC uses simple English-like instructions.
- It is mainly used for teaching programming.