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

UC2 Week 7 Topic: Basic Programming I Sub-Topic: Introduction To BASIC Programming

The document discusses the BASIC programming language, including its history, versions, rules, character set, variables, constants, key statements, expressions and operators. BASIC was developed in 1964 to teach programming and has undergone changes resulting in different versions. The summary outlines the main topics covered in the document.

Uploaded by

Etta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

UC2 Week 7 Topic: Basic Programming I Sub-Topic: Introduction To BASIC Programming

The document discusses the BASIC programming language, including its history, versions, rules, character set, variables, constants, key statements, expressions and operators. BASIC was developed in 1964 to teach programming and has undergone changes resulting in different versions. The summary outlines the main topics covered in the document.

Uploaded by

Etta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

UC2 WEEK 7

Topic: BASIC PROGRAMMING I


Sub-Topic: Introduction to BASIC Programming
BASIC stands for Beginners All-purposed Symbolic Instruction Code. It was developed in 1964 by
Professor 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.
Versions of BASIC
1. BASICA
2. GWBASIC
3. Torbo BASIC
4. Quick BASIC
5. VB.NET
RULES OF BASIC
Every programming language has a set of rules that have to be followed while writing a program,
following are some rules of BASIC language:
1. All QBasic programs are made up of series of statements, which are executed in the order in
which they are written.
2. Every statement should have at least one QBasic command word. The words that BASIC
recognizes are called keywords.
3. All the command words have to be written using some standard rules, which are called “Syntax
Rules”. Syntax is the grammar of writing the statement in a language. Syntax Errors are
generated when improper syntax is detected.

BASIC CHARACTER SET


1. Alphabetic Characters – A to Z
2. Numeric Character – 0 to 9
3. Special Characters – 0 + % ^ # = ( ) etc

BASIC VARIABLES
A variable is a quantity that changes during the execution of a program. It can also be defined as a name
that is used to represent some storage location.
Types of Variables
1. Numeric Variables
2. String Variables
CONSTANTS
A constant is data that remains the same as the program runs (executes).
BASIC allows two types of constants:
1. Numeric constant.
2. Alpha-Numeric or string constant.

KEY BASIC STATEMENTS


The following are BASIC statements and a brief description:
REM - makes a remark or comment about the program. The use of remark statements improve the
readability of the program. E.g.
REM Program to find the square root of a number.
LET - is used when a formula is used in the program. It is used to assign a numeric or string value to a
variable and can also be used to write out a formula. E.g.
LET X = 5
LET Area = π * Radius ^ 2
LET NAME$ = FIRST$ + LAST$
PRINT - displays the programs results of a BASIC program on the screen. E.g.
PRINT Sum
PRINT “I like writing codes”
READ - is used with a DATA statement to read values. E.g
READ A, B, C
DATA 2, 4, 6
DATA - is the list of values used in the READ statement. E.g
READ A, B, C
DATA 2, 4, 6

GO TO - changes the sequence order of a program. It transfers program control from a line number to a
given line number. E.g.
10 REM
20 READ $NAME, AGE, SCORE
30 INPUT “Thomas”, 10, 98
40 IF $NAME = “Tom”
50 GOTO 90
60 PRINT “My name is Thomas, I am 10 years old and I scored 98”
70 GOTO 90
80 PRINT “My name is Tom, I am 10 years old and I scored 98”
90 END
IF-THEN - conditional statement that decides if the program will change. It is used to execute a single
statement on a conditional basis. E.g.
10 IF X < 0 THEN
20 PRINT X
IF-THEN - ELSE – This is a conditional statement used to execute multiple conditional statement. It
permits one or two different groups of statements to be executed depending on the logical test outcome.
The syntax for IF – THEN – ELSE is:
IF logical expression THEN
Executable statement
ELSE
Executable statement
END IF
FOR NEXT: This is an unconditional statement that is used to carryout unconditional looping. The
format is:
FOR I = 1 TO 10
PRINT I
NEXT I
STOP or END – The STOP statement is used to stops the execution of a program at any point in the
program. The END statement indicates the actual end of a program. The STOP statement can appear
many times but the END statement can only appear once at the end of the program. E.g.
90 END
INPUT - tells the computer that information is needed to be typed into the terminal for interaction with
the program. It is used to enter data into our program during program execution. E.g.
80 INPUT A, B, C
90 INPUT N$, M$, Factor
Expressions and Operators
In programming, an expression can be defined as the combination of operand and operator which is to be
evaluated to produce answer. Operands are the data items involved in an expression. Operators determine
the action to be carried out on the operand in the expression. For instance in the statement: LET C = A +
B, A and B are the operands while “+” is the operator.
There are three major types of expression in BASIC. They are:
i. Arithmetic expression
ii. Relational Expression
iii. Logical expression
Arithmetic Expression and Arithmetical Operator
BASIC arithmetic expression is used to represent mathematical formulae in BASIC programming. Below
is a list of BASIC arithmetic operators:
Arithmetic Operator

SYMBOL NAME FUNCTION

^ Upper caret Exponential

/ Slash Division

* Asterisk Multiplication

+ Plus Addition

- Minus Subtraction

Arithmetic Expression

Mathematical formulae BASIC Expression

lbc L*B*C

ut+1/2at^2 U*T+1/2*A*T^2

2(lb + bh + lh) 2*(L*b+B*H+L*H)

PTR/100 P*T*R/100

Relational Expression
Relational Expression is used for comparison of two or more data items. BASIC relational operators are
listed below:

SYMBOL NAME

< Less than

> Greater than

= Equal to

<> Not equal to

<= Less than or equal to

>= Greater than or equal to

Logical Expression
Logical expression involve is an expression involving two or more relational repression joined by logical
expression. BASIC logical operators are:
i. AND
ii. NOT
iii. OR

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy