BASIC PROGRAMMING J2

BASIC Programming Language

TOPIC: BASIC programming Language

CLASS: JSS Two

Origin of and Features of BASIC

BASIC stands for Beginner’s All-purpose Symbolic Instruction Code. It was developed in 1960 by John Kemeny and Thomas Kurtz to teach students at Dartmouth College. It has undergone series of historical development, which has resulted in several forms of the language.
BASIC is now in form of VB.NET (Visual Basic.Net). The majority of BASIC languages use program translators called interpreters to allow the computer understand and obey the BASIC statements in the computer program. Examples of such interpreters are:
BASICA
GwBASIC
Turbo BASIC
Quick BASIC

BASIC Character Set

These are the symbols used in BASIC programming language. They include:
The characters used in BASIC language include:
i. Alphabetic Characters: BASIC alphabetic characters consist of letters (A to Z)
ii. Numeric Characters: Numbers from 0 to 9 are used in BASIC language
iii. Special Characters: Special characters are characters that are not letters or numbers. They include punctuation marks, accent marks, ASCII control characters, formatting characters. Examples + % ^ # = ( ) etc

BASIC Arithmetic Expressions

An expression is the combination of operands and operators. Operands are the data items involved in an expression, while operators determine the action to be carried out on the operand in the expression. For instance in the expression X + Y; "X" and "Y" are the operands while “+” is the operator.
BASIC Operators used to perform arithmetic operations are:

Operation Operators
Addition +
Subtraction -
Multiplication *
Division /
Exponentiation ^

Rules for BASIC Arithmetic Expressions

Every arithmetic expression must appear on a single line. There is no superscript in BASIC as we find in algebra.

Algebraic Expressions versus BASIC Expressions

BASIC variables

Variables are names that are used to represent some storage location.

Types of Variables

1. Numeric Variables: These are used to store numeric values such as 23, 98, 1.44 etc. Examples of numeric variables are; N, Y, P, SUM, AVERAGE, etc
2. String Variables: These are used to store alphabetic and alpha-numeric values. The last character in a string variable names is the dollar($) sign. E.g. Name$, Color$, X$, etc

Constants
Constants are values stored or assigned to variables.
Types of Constants in BASIC
BASIC allows two constants which are;
Numeric constant: Numeric constant in BASIC is any signed or unsigned number.
Alpha-Numeric or string constant: It consists of the combination of letters, digits, and other symbols that are treated in a manner completely analogous to a numeric constant. They are enclosed within inverted commas.

BASIC Key Statements

BASIC key statements are very important words used in BASIC programming Language. They include:
CLS Statement
Statement is used to clear the screen of any text or graphics that have been displayed. CLS is useful when you want to start with a clean slate and display new information on the screen.
LET Statement
The LET statement is used to assign a numeric or string value(s) to a variable. The LET statement must consist a variable, an equal to sign and an expression.
Example
LET X = 12
LET B$ = “Deborah”

INPUT Statement
The INPUT statement is uses to enter data into the computer during program execution.
Example
INPUT A, B, C
INPUT N$, M$, Factor

READ-DATA statement
READ and Data statements are BASIC key statement that must be used together to put data in a line of the program and to read the data when it is needed.
Example
READ A, B, C
DATA 5, 6, 7
LET SUM = A+B+C
PRINT SUM
END

REM (Remark) Statement
The REM statement is used to insert comments or remarks into a BASIC program. The use of remark statements improves the readability of the program. It has no effect on the program execution.
Example
REM program to add six numbers

PRINT statement
This statement is used to transmit data from the computer memory to the screen.
Examples
PRINT 45
PRINT A, B, C
PRINT “cmpnote blog”

Program Terminators (END and STOP)
STOP and END statement
The STOP statement is used to terminate the execution of a program at any point in the program. The END statement indicates the actual end of a program. The STOP statement may appear many times and anywhere, whereas an END statement can only appear at the end of a program and only once.
Example
REM END statement
PRINT “Good morning”
END

GO TO statement
This statement transfers program control from the line number that contains the statement to the specific number after GOTO statement.
Example
10 REM GO TO statement
20 GOTO 40
30 PRINT “Good m orning”
40 END
In the case above the program’s control is transferred from line 20 to line 40. This means that the program would end when the execution gets to line 20.

Some Simple BASIC Programs

Example 1
Write a Program in BASIC to find the average of six numbers
Solution
10 REM Programs to find the average of six numbers
20 REM Numbers given
30 INPUT "Type in the first number"; A
40 INPUT "Type in the second number"; B
50 INPUT "Type in the third number"; C
60 INPUT "Type in the fourth number"; D
70 INPUT "Type in the fifth number"; E
80 INPUT "Type in the sixth number"; F
90 LET AVERAGE = (A+B+C+D+E+F)/6
100 PRINT "Average is"; AVERAGE
110 END

Example 2
Program to calculate the perimeter and Area of a Rectangle
REM program to calculate the perimeter and Area of a Rectangle
INPUT “Input the length”; L
INPUT “Input the breath”; B
LET PERIMETER = 2 * (L + B)
LET AREA = L*B
PRINT “the perimeter is”; PERIMETER
PRINT “the area is”; AREA
END

Comments

  1. OWOGBEMI SEUN ADEWALE29 September 2020 at 12:42

    Kudos to you bro. Can you please work on Data Processing?

    ReplyDelete
  2. Basic programming comprises of weeks 2 and 3. Week 2 says basic language, meaning of BASIC, BASIC character set,key BASIC statements and simple BASIC statement, while week 3 says simple BASIC statements, examples of simple BASIC statements and simple BASIC program.please how do I divide this notes into the two different lessons. Help a sister please. Thanks for the goog job. God bless

    ReplyDelete
    Replies
    1. I don't know the class you are referring to but for SSS 1 use this link thank you https://cmpnote.blogspot.com/p/basic-programming-language.html?m=1

      Delete
  3. Don't you guys think BASIC is getting kinda outdated and we should be teaching student more demanded and more powerful languages like Python and maybe JavaScript even?

    ReplyDelete
    Replies
    1. You're right but the current Nigeria curriculum requires it to be taught in secondary schools

      Delete
  4. Wow seems interesting

    ReplyDelete

Post a Comment

Popular posts from this blog

90 Objective Examination Questions in Major Subjects

Complete Computer Studies/ICT Curriculum for JSS 1 to SSS 3

JSS One Objective Questions in Computer Studies/Information Technology