You are on page 1of 15

PROGRAMMING

TAXONOMY OF PROGRAMMING

PROGRAMMER: This is a person that indulges or that is an expert in writing computer


codes. His major responsible is to write programs that performs a given or specified
function.

PROGRAM: This implies the written instruction which the computer takes in and acts
upon.

PROGRAMMING LANGUAGE: This indicates the language of choice for which the
programmer communicates with the computer machine. In other words, this points to the
language with which he codes. A programming language defines a set of instructions that
are compiled together to perform a specific task by the CPU (Central Processing Unit).
The programming language mainly refers to high-level languages such as C, C++, Pascal,
Ada, COBOL, etc.

Each programming language contains a unique set of keywords and syntax, which are
used to create a set of instructions. Thousands of programming languages have been
developed till now, but each language has its specific purpose. These languages vary in
the level of abstraction they provide from the hardware. Some programming languages
provide less or no abstraction while some provide higher abstraction. Based on the levels
of abstraction, they can be classified into two categories:

Low-level language

High-level language

The image which is given below describes the abstraction level from hardware.

Low level language; are very close to the hardware and are of two types:
Machine language

Assembly language

Machine language can only understand (0,1) which requires extensive knowledge of the
configuration and system architecture. it fetches data, execute and then write it back to the
memory in form of (0,1). It is faster to execute giving that it's the language computer
understands. But for humans it is difficult to understand. However, you can't run on two
different machines, because you'll need to rewrite.

Assembly language understands symbols known as mnemonics. (E.g. ADD for +, Sub for
- move for moving etc.) assembler generates machine code for assembly language.

High level language is close to humans and can easily be understood by humans.
Compilers and interpreters are used to translate to machine readable. A compiler takes a
complete code and coverts it into machine code while interpreter reads code line by line.

Two types of high-level languages

*Procedural

*And object oriented.

Procedural programs are written in sequence of steps. For example, recipe for cooking.

While object-oriented programs are an interaction of functions between objects. Eg start


wake up or continue sleeping. It maintains their own data

Definition of Algorithm

Writing a logical step-by-step method to solve the problem is called the algorithm. In


other words, an algorithm is a procedure for solving problems. In order to solve a
mathematical or computer problem, this is the first step in the process.

An algorithm includes calculations, reasoning, and data processing. Algorithms can be


presented by natural languages, pseudocode, and flowcharts, etc.
Part 2: Definition of Flowchart

A flowchart is the graphical or pictorial representation of an algorithm with the help of


different symbols, shapes, and arrows to demonstrate a process or a program. With
algorithms, we can easily understand a program. The main purpose of using a flowchart is
to analyze different methods. Several standard symbols are applied in a flowchart:

Terminal Box - Start / End

Input / Output

Process / Instruction

Decision
Connector / Arrow

The symbols above represent different parts of a flowchart. The process in a flowchart can
be expressed through boxes and arrows with different sizes and colors. In a flowchart, we
can easily highlight certain elements and the relationships between each part.

Part 3: Difference between Algorithm and Flowchart


If you compare a flowchart to a movie, then an algorithm is the story of that movie. In
other words, an algorithm is the core of a flowchart. Actually, in the field of computer
programming, there are many differences between algorithm and flowchart regarding
various aspects, such as the accuracy, the way they display, and the way people feel about
them. Below is a table illustrating the differences between them in detail.

Algorithm Flowchart
It is a procedure for solving
It is a graphic representation of a process.
problems.
The process is shown in step-by-step The process is shown in block-by-block
instruction. information diagram.
It is complex and difficult to
It is intuitive and easy to understand.
understand.
It is convenient to debug errors. It is hard to debug errors.
The solution is showcased in natural
The solution is showcased in pictorial format.
language.
It is somewhat easier to solve
It is hard to solve complex problem.
complex problem.
It costs more time to create an
It costs less time to create a flowchart.
algorithm.
1. what is the full meaning of Q-basic

2. what a pseudo code for finding the area of a room.

Here is the pseudo code:

area = width x length.


Display "What is the room's width?".

Input width.

Display "What is the room's length?".

Input length.

Display area.

To construct a Qbasic program, we have to arrange some standard element. The element
used in qbasic is as follows

• character set

• variables

• constant

• operators and operands

• expressions

• statements

CHARACTER SET

QBASIC has the character set consisting of the following elements:

1. Alphabets: A, B, C.Z

2. Digits: 0, 1, 2. and

3. Special characters: + - */()., $;:= >,<,^

The symbol A (caret) is used to denote exponentiation operator, the symbol * (asterisk) is
used to denote multiplication and other symbols; have their usual meanings

CONSTANTS

A quantity in a computer program which does not change its value during the execution of
the program is called a constant. QBASIC allows the following constants:
Numeric constant: The numeric constant is one that is formed by a sequence of digits 0,
1, 2 and may include a decimal point. A numeric constant may be an integer or a real
number. 383, +57, 0, -6.2 and 6.15E4 are valid numeric constants. The number 6.15E4, in
fact, represents 6.15 * 104. The notation E is used to represent the exponential form. The
number after E is the exponent which can be positive or negative. However, its length
cannot exceed two digits. Is also important to keep in mind that:

QBASIC does not distinguish between an integer and fraction.

Commands are not allowed in a numeric constant the limit on the number of digits that
can be used varies from computer to computer. Normally, a numeric constant can have up
to a maximum of eight digits.

String Constant: A string constant consists of a sequence of characters which must be


enclosed by a quotation mark.

VARIABLES

The quantity which may change its values during the execution of the program is called
the variable.

In QBASIC, variables are also of two types:

Numeric variable: Numeric variable can assume numeric value and is represented by an
alphabet or an alphabet followed by another alphabet or digit. For example A, C, A2,
ABC, A6 etc, represent numeric variables.

String variable: A string variable is represented by an alphabet followed by dollar($)sign.


It should be kept in mind that while constructing the string varialble, dollar($) should be
the last character. For example, B$, NAME$, BOOK$, etc are valid string variables.

EXPRESSION

An expression can be a string, or numeric constant, a variable or a combination of


constants, variables with operators which return a single value.

OPERANDS
Operands are the data or variables on which mathematical, logical and string operations
take place.

OPERATORS

Operators are the symbols, which are used in arithmetic operations, logical expressions,
and string expressions.

STATEMENTS

A statement is a set of instructions written using keywords or commands of QBASIC.


Every programming language uses keywords as a statement with certain syntax.

THE STRUCTURE OF QBASIC

QBasic is a procedural language. Unlike object-oriented language, it has no standard


structure according to programming style rule. Howbeit, it does have structure for
programmers to follow.

Guide to QBasic Structure

i. Line Number: Programs in QBasic are easily written with line numbers for
readability purpose.
ii. CLS: This means CLear Screen
iii. REM: Implies REMark - Comment.
iv. END: To signify the end of a program

Guide to QBasic Structure- Illustration For example, the program below does nothing but
shows the guide to QBasic Structure:

1 CLS

2 REM

3 END

OR

10 CLS
11 REM

13 END

GARBAGE IN & OUT IN QBASIG

To feed/supply data unto the computer system using QBasic, we make use of any of the
following two commands:

I. INPUT statement
II. READ&DATA statement

To fetch/retrieve stored or inputted data from the computer system using QBasic, we
make use of PRINT statement.

OUTPUT STATEMENTS

These are statements that are used for fetch/retrieve/show to screen, inputted or stored
data from the computer system. The major/basic output statement used in QBasic is called
PRINT. Others will be treated under FILE.

OUTPUT STATEMENTS- Usage & Format

PRINT can be used in two ways:

i. For outputting literals e.g. PRINT "I am a programmer

ii. For outputting variables (values of an identifier) e.g.

PRINT radius

(where radius is a variable having a particular value that has previously been inputted
/captured/ stored)

OUTPUT STATEMENTS -Ilustration

5CLS

10 REM
15 PRINT "l am a Programmer"

20 END

Press F5 to RUN

OR

Click on RUN and click on START

RUN well? Good! Save your work now!! Click on FILE, then click on SAVE. Remove
the highlighting and save accordingly. Please ensure you preserve the .bas, it is the
filename extension for QBasic, just as .doc is to MS-Word.

OUTPUT STATEMENTS-Illustration I

5 CLS

10 REM

15 INPUT radius

20 PRINT radius

25 PRINT radius* 2

30 END

Press F5 to RUN

OR

Click on RUN and click on START.

RUN wel? Good! Press any KEY to return to the Coding Screen.Save your work now!!
Click on FILE, then click on SAVE. Remove the highlighting and save accordingly.
Please ensure you preserve the .bas, it is the filename extension for QBasic, just a .doc is
to MS-Word.
OUTPUT STATEMENTS-IlIustration II

5 CLS

10 REM

15 INPUT radius

20 PRINT radius

25 PRINT radius * 2

30 END

Press F5 to RUN

OR

Click on RUN and click on START.

Exercise

Code in QBasic to output the literals:

BIO-DATA Quiz

........................

HE was born and brought upin Lagos.

He hails from Kwara.


He settles down in Ondo.

Who is He?

Solution I

5 CLS

10 REM

15 Print "BIO-DATA Quiz"

20 Print".............................."

25 Print "He was born and brought up in Lagos."

30 Print "He hails from Kwara."

35 Print "He settles down in Ondo."

40 Print

45 Print "Who is He?"

50 END

Exercise II

Given two variables: birthyear

And currentyear, input values

For the two variables and

Compute your AGE by finding

The difference of the two

Variables.

Solution I

5 CLS

10 REM
15 INPUT birthyear

20 INPUT currentyear

25 PRINT currentyear-birthyear

30 END

INPUT STATEMENTS

These are statements that are used for feed/supply data unto the computer system.

TWO Types:

Input Method

Read&Data Method

INPUT STATEMENTS cont'd

INPUT Method

This is used where the program given is a closed problem (e.g. values not specified).

e.g. INPUTA

OR

INPUT "Enter value for A: ",A

Here the value of A is expected to be inputted.

INPUT STATEMENTS cont'd I

Programming Example

Code in QBasic to solve:

Z = x2 +w/y

Gi) F= b2/4ac

INPUT STATEMENTS-Ilustrationl

Solutions
5 CLS

10 REM

15 INPUT "Enter value for X: ", x

20 INPUT "Enter value for W: ", w

25 INPUT "Enter value for Y: ", y

30 Let Z = (x*x) + (w/y))

35 PRINT "The answer is: ", Z

40 END

INPUT STATEMENTS-Illustration l

Solutions

5 CLS

10 REM

15 INPUT "Enter value for A: ", a

20 INPUT "Enter value for B: ", b

25 INPUT "Enter value for C: ", c

30 Let F= (b^2)/ (4*a*c))

35 PRINT "The answer is: ", F

40 END

INPUT STATEMENTS Cont'd

READ Method

This is used where the program given is an open problem (e.g.

values specified).

e.g. READ A
DATA 7

OR

READ A, B, C

DATA 7, 15, 87

Here there is no need using INPUT to enter the value of A because

it is already given.

INPUT STATEMENTS cont'd

Programming Example

Given:

t= 15, u = 210, s = 14, r=11

Code in QBasic to compute:

(I) v = t + (u-r)

(ii) W = (u + s3)/t2t2

INPUT STATEMENTS-Illustration I

Solutions

5 CLS

10 REM

15 READt, u, r

20 DATA 15, 210, 11

30 Let V = (t + (u-r))

35 PRINT "The answer is: ", V

40 END

INPUT STATEMENTS -Illustration II


Solutions

5 CLS

10 REM

15 READ u, s, t

20 DATA 210, 14, 15

30 Let W = ((u/(*2)) + ((S*2)/(*2))

35 PRINT "The answer is: "; W

40 END

You might also like