0% found this document useful (0 votes)
2 views

BASIC PROGRAMMING (1)

The document provides an overview of BASIC programming, detailing various BASIC statements, data types, constants, variables, and operators. It explains the purpose of key statements like CLS, REM, LET, INPUT, and PRINT, as well as the classification of data types into numeric, string, and boolean. Additionally, it outlines the rules for forming variable names and describes different types of operators used in BASIC programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

BASIC PROGRAMMING (1)

The document provides an overview of BASIC programming, detailing various BASIC statements, data types, constants, variables, and operators. It explains the purpose of key statements like CLS, REM, LET, INPUT, and PRINT, as well as the classification of data types into numeric, string, and boolean. Additionally, it outlines the rules for forming variable names and describes different types of operators used in BASIC programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

BASIC PROGRAMMING 1

BASIC STATEMENT

BASIC Statements are those BASIC keywords used in the program to perform certain function.

BASIC Statements include the following:

1. CLS,: This stands for clear screen. This statement is used to clear the screen of the computer monitor.

2. REM: This stands for remark. This statement is used to give comment to a program.

Single quotation mark ( ' ) can be used in place of REM.

Note: REM and CLS are non executable statements

3. LET: This statement is used to assign a value to a variable. Eg: LET A = 50

4. INPUT: This statement is used to assign a value to a variable during program execution. Eg,: INPUT A

5. READ and DATA,: READ statement states the variables while the DATA statement assigns values to
these variables.

Example: READ X, Y, Z,

DATA 7, 15, 12

Note: LET, INPUT, and READ and DATA Statements are assignment statements.

6. PRINT Statement: This is an output Statement used to display the result of a program.

7. END Statement: This statement is used to terminate a BASIC program.

8. IF.....THEN........ELSE: This statement is used to perform comperisons or make decisions.

Others include GOTO Statement, FOR...... NEXT Statement, etc.

BASIC DATA TYPES

BASIC data type is a classification of data which tells the compiler or interpreter how the programmer
intends to use the data.

The data type defined the operations that can be done on the data, the meaning of the data and the
way value of the type can be stored.

BASIC data type include the following:

1. Numeric Data type: Numeric data type includes the following,:

a. Integer: This is any positive or negative whole number. Eg: 25, 235, 2546, etc.
b. Floating Point numbers: These are numbers in which the digit and the location are treated separately.
Eg. 2.5 x 10

2. String: They are textual data enclosed in double quotation mark. For example,: "JOHNSON".

3. Boolean data type: A boolean data type is the data type that represents either true or false value, Yes
or No value or On or Off(1 or 0) value.

CONSTANTS

Constans are quantities that cannot be changed during program execution.

There are two types of constants, namely:

1. Numeric Constant

2. String Constant

1. Numeric Constant: These are values that are fixed throughout the program execution. They are
classified into two, namely;

a. Integer Constant: This cf whole numbers. Eg. 30, 75, 180, etc.

2. String Constant; A string Constant is a sequence of characters surrounded by double quotes.

Eg. "CHIMA" , " MARCH" , etc.

VARIABLE

A variable is a name that represents numeric quantity or a string. It is also a name that is used to
represent some storage location in computer memory.

There are two types of variables, namely:

1. Numeric Variables

2. String Variables

1. Numeric Variables: This is a variable that is used to store numeric data. It represents or stores a
number.

a. Integer Variable names: These are written with % sign as the last character.

Eg. RATE% = 500

b. Single Precision Variable names: These are written with # sign as last character. Eg. UNIT#

2. String Variable: This is a variable that represents or stores a string data. String Variable names are
written with dollar sign ($) as last character.
Example: NAME$ = "TUNDE"

Rules for Forming a Variable Name

1. The first character must be a letter.

2. A variable name must not contain any special character which include mathematical operators,
commas, blank space, question mark, etc.

3. A QBASIC reserved or keyword must not be used as a Variable name. Eg. REM, INPUT, PRINT etc.

4. A Variable name may contain numeric digit. Eg. RITA3, PURUTY2, etc.

BASIC OPERATORS

An operator is a symbol used to carry out operations in any program in BASIC Programming language.
An operator acts an data items called operands.

TYPES OF BASIC OPERATORS

(a) Arithmetic Operators

(b) Relational Operators

(c) Logical Operators

(d) String Operators.

(a) ARITHMETIC OPERATORS: These are symbols used for various mathematical calculations.

Operators Meaning Example

+ (Plus sign) Addition X+Y

- (Minus) Subtraction X-Y

* (Asterisk) Multiplication X*Y

/ (Forward Slash) Division X/Y

^ (Caret) Exponentiation X^2

(b) RELATIONAL OPERATORS: These are symbols used to compare different operands. They produce
logical results. Eg. =, <, >, <>,

(c) LOGICAL OPERATORS: These are BASIC operators that produce logical answers when two logical
expressions are compared. Eg. AND, OR, NOT, etc

(d) STRING OPERATORS: String Operator joins two or more character strings into a single character string
through the process known as a string concatenation. Eg. "Good" "+" "Morning" will give the result.
Good morning.

You might also like