You are here

BASIC PROGRAMMING

WEEK ONE : COMPUTER STUDIIES

BASIC PROGRAMMING

The full meaning of BASIC is Beginners All-purpose Symbolic Instruction Code. This programming language was developed in 1964 at Dartmouth College, U.S.A by Professors John Kemeny and Thomas Kurtz. It was centered on developing a means of teaching students a simple language for programming. It is a high level language and it consists of statements written English language and mathematical notations. BASIC programming language has many versions which include Gwbasic, Qbasic, Basica, Fox basic and Visual BASIC.

 

DATA TYPES IN BASIC PROGRAMMING

Data can be classified in BASIC programming language either as a numeric or character string.

  1. Numeric data type : Thisinvolves only both positive and negative numbers

While writing a BASIC programming language numerical-data names are represented by a single letter A - Z followed by a single digit (0-9).

Some examples of numerical data are A, B, K 8, Z3, etc

  1. Character String : comprises of a mixture of digits, letters, alphabets or special characters (e.g. punctuation characters).

While writing a BASIC  programming language character, data names arerepresented by   a single letter of the alphabet (A-Z) followed by a dollarsymbol $.

THE PROGRAMMING PATTERN OF A BASIC PROGRAM

Every Programming Language has an Order in which they are written. This order must be followed in order to for the Program to be executed.

 

 BASIC program pattern appears this way.

  1. One instruction or statement is written per line.
  2. Every line has to begin with a line-number.
  3. Line numbers has to be positive integers which varys from 1 to 9999
  4. Line number has incremental steps of 10 incase new of codeneeds to be added.

BASIC PROGRAMMING KEYWORDS

  1. Input

 Input command allows a value, numeric, or character string to be typed at the keyboard of a computer and stored in the computer’s memory at the specified data name.

Example, INPUT X : This will allow a numeric value for x to be entered via the keyboard and stored in the memory under the data-name X

  1. PRINT

The PRINT statement allows the contents of the data name specified to be displayed on the screen.

Example: Print S (this will display a value for S on the screen).

  1. LET

The LET statement is an assignment statement that evaluates an arithmetic expression and stores the result.

Example: Let T = 20 (it will assign T to be 20)

  1. REM

The REM statement makes a remark about the program; it is usually when a formula is applied in the program. REM statement is not an executable statement.

Example: REM followed by a space in front of a line will remark the line in the program.

  1. DATA

Data can be placed anywhere in the program before the end statement. The DATA statement tells the system that the numbers specified in the constant list are to be stored in the memory.

Example: By keying in ‘DATA’, you are to specify the data names contained in the program.

 

  1. READ

The READ statement helps values to be gotten from the DATA block. The READ statement gives meaning to the values gotten from the variable lists.

Example The variable list consists of variables separated from one another by commas that will be needed in the program.

  1. END

In aspect of programming, this statement terminates/ends the program. It must be the highest numbered statement in the program.

Example:  END, END IF….

Some Basic Arithmetic Operations

  • Constant

A constant is a quantity whose numerical value does not change and it is clearly stated. The constant values can be expressed with or without decimal points and may be either negative or positive. Some examples of constants are 100, -398, and 0.00067.

  • Variables

A variable is the name given to a quantity that are able to change and can assume different numerical values. Some examples of variables are T, Y, M1.

 

Simple BASIC Programs

We are going to write simple basic programs using BASIC programming commands like Let, Input, Print, Read and Data. We will also use Basic Arithmetic Operations

  1. Write a simple basic program to add three numbers

10 Let the Numbers be W1, W2, W3

20 Input “First Number,” W1

30 Input “Second Number,” W2

40 Input “Third Number,” W3

50 Let X = W1+ W2

 60 Print “Sum”, X

70 End

 

  1. Write a simple basic program to multiple two numbers

10 Let the Numbers be X1, Y2,

 20 Input “First Number,” X1

30 Input “ Second Number,” Y2

40 Let A = X1*Y2

50 Print “Product ”, A

 60 End

 

Summary

  • BASIC means (Beginners All-purpose Symbolic Instruction Code).

The language was developed in 1964 at Dartmouth College,                    

U.S.A by Professors John Kemeny and Thomas Kurtz; '

  • BASIC data types are numeric and character strings
  •  The format for BASIC program is:
  1. One instruction or statement per line;
  2. Each tine must begin with a line-number;
  3. Line numbers must be positive integers.
  4. Line number should increase in steps of 10 to allow for insertion of extra lines if the need arises.

 

Some basic programming language commands

  1. Input - The input command allows a value, numeric, or character string to be typed at the keyboard of a computer and stored in the computer’s memory a the data name specified.
  2. Print - statement allows the contents of the data name specified to be displayed on the screen.

 

 

CLASS EXERCISE

  1. Give a Brief History of BASIC Programming Language.
  2. How many Data types do we have in BASIC programming Language? List them.
  3. List 5 BASIC Programming Language Keywords you know?
  4. Write a BASIC programming Language that adds two numbers and multiplies their sum to another number.

 

Subject: 
Computer Studies

User login

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.