COMPUTER STUDIES

BASIC PROGRAMMING LANGUAGE 1

BASIC is one of the earliest and simplest programming languages. It is a very powerful language as a tool for an amateur programmer.

In other words, it is used to teach beginners the rudiments of programming.

BASIC is an acronym from Beginner’s All-purpose Symbolic Instruction Code. It is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use. The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide computer access to non-science students.

It has undergone series of development which has resulted into having several versions such as Tiny BASIC, Microsoft BASIC, C BASIC, Apple Soft BASIC (for Apple II), GW-BASIC (for IBM PC), Turbo BASIC (from Borland), Microsoft Quick BASIC, VBASIC (Visual Basic), VB.Net (Visual BASIC Net).

 

Rules for BASIC Programming

  1. The first character for your data name must be alphabet (A-Z).
  2. Each statement must begin with a line number.
  3. There must not be a full stop after each line of statement.
  4. Each program must be terminated by END or STOP statement.
  5. Each line must contain only one BASIC program statement.
  6. All expressions must be written in capital letters.

 

BASIC CHARACTER

A character is any letter, digit, punctuation, symbol or any other sign used in the presentation of information in any language. BASIC has the following character set.

 

BASIC FUNDAMENTALS

The two fundamentals of BASIC programming language are the constant and variable.

 

CONSTANT: Constants are static value the BASIC interpreter uses during program execution. There are two types of constant, which are:

(i) String Constant: A string constant is a sequence of 0 – 255 alphanumeric characters enclosed in a double quotation marks. For example,

“DON STEVE”

“DON STEVE BLOG”

 

(ii) Numeric Constant: Numeric constants can be positive or negative. For instance, if the number 50,200 were to be entered as a constant, it would be typed as 50200. There are five types of numeric constants: integer, fixed-point, floating-point, hexadecimal, and octal.

 

Single-Precision and Double-Precision Form for Numeric Constants

Numeric constants can be integers, single-precision, or double-precision numbers. Integer constants are stored as whole numbers only. Single-precision numeric constants are stored with 7 digits (although only 6 may be accurate). Double-precision numeric constants are stored with 17 digits of precision, and printed with as many as 16 digits.

 

A single-precision constant is any numeric constant with either:

  1. Seven or fewer digits.
  2. Exponential form using E.
  3. A trailing exclamation point (!).

 

A double-precision constant is any numeric constant with either

  1. Eight or more digits.
  2. Exponential form using D.
  3. A trailing number sign (#).

 

The following are examples of single precision and double-precision numeric constants:

 

BASIC VARIABLES

Variables are the names that can change during the execution of a program, or from one execution of a program to the next. The value of a variable may be assigned specifically, or may be the result of calculations in your program. If a variable is assigned no value, BASIC assumes the variable’s value to be zero. There are two types of variable, which are:

i) Numeric Variable: A numeric-variable name maybe any single letter of the English alphabet (A to Z), or a single letter followed by any single decimal digit (0 through 9). It can be assigned only a numeric value either integer, single precision or double precision.

 

(ii) String Variables: These are variables that can only be assigned a character string value. Examples are:

K$ = “Happy day”

Lagos$ = B$, where K$ and Lagos$ are string variables.

 

Type Declaration Characters

Type declaration characters indicate what a variable represents. The following type declaration characters are recognized:

 

DATA-NAMES

It is also known as variables or identifiers. In BASIC language, the minimum requirement for the composition of data-names is:

i) For Numeric data-names: A single letter of the alphabet (A -Z) followed by a single digit (0 -9). Examples are A, K, T, J0, G5, F9 etc.

 

ii) For character string data-name: A single letter of the alphabet (A – Z) followed by a dollar symbol $. Examples er to are A$, B$, C$ etc.

Whenever the programmer is restricted to using data-name that only contain several characters, it is advisable to write a glossary of the data-names used in the design of the program and the corresponding data-name used in coding the computer program into BASIC. Many modern dialects of BASIC will permit data-names to contain enough characters for the name to be meaningful. The two major BASIC dialects are explained below:-

(a) Microsoft: BASIC variable names may be of any length. If the name is longer than 40 characters, however, only the first 40 characters are significant. The characters allowed in a variable name are letters and numbers and a decimal point. The first character must be a letter. A variable name may not be a reserved word. A variable name ending with one of the following characters implies a type declaration.

 

(b) BBC / Electron: No restriction on the length of the data-name, however, there must be no spaces in the middle of a data-name. All data-name must start with a letter, no punctuation mark must be used in the name and data-name must not begin with BASIC reserve words. The character set up used in the data-name can be either upper case, lower case or a mixture of both cases. Integer types can be distinguished from real numeric types by the use of the character % after the data-name. String data types are expressed in the conventional manner.

 

GENERATION OF BASIC LANGUAGE

  1. First Generation BASIC language: They supported simple data types, loop cycles and arrays. Examples are MSX BASIC and GW-BASIC. The program below is an example of first generation program.
  2. Second generation: BASICs introduced a number of features into the language, primarily related to structured and procedure-oriented programming. Usually, line numbering is omitted from the language and replaced with labels for GOTO and procedures to encourage easier and more flexible design. Examples are QuickBASIC and PowerBASIC.
  3. Third generation: BASIC introduced features to support object-oriented and event-driven programming paradigm. Most built-in procedures and functions are now represented as methods of standard objects rather than operators. Examples are Visual Basic, REALbasic, StarOffice Basic and BlitzMax.

Leave a Reply

Your email address will not be published. Required fields are marked *

Blogarama - Blog Directory