Professional Documents
Culture Documents
TAXONOMY OF PROGRAMMING
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.
*Procedural
Procedural programs are written in sequence of steps. For example, recipe for cooking.
Definition of Algorithm
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.
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
Input width.
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
• expressions
• statements
CHARACTER SET
1. Alphabets: A, B, C.Z
2. Digits: 0, 1, 2. and
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:
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.
VARIABLES
The quantity which may change its values during the execution of the program is called
the variable.
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.
EXPRESSION
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
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
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.
PRINT radius
(where radius is a variable having a particular value that has previously been inputted
/captured/ stored)
5CLS
10 REM
15 PRINT "l am a Programmer"
20 END
Press F5 to RUN
OR
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
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
Exercise
BIO-DATA Quiz
........................
Who is He?
Solution I
5 CLS
10 REM
20 Print".............................."
40 Print
50 END
Exercise II
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 Method
This is used where the program given is a closed problem (e.g. values not specified).
e.g. INPUTA
OR
Programming Example
Z = x2 +w/y
Gi) F= b2/4ac
INPUT STATEMENTS-Ilustrationl
Solutions
5 CLS
10 REM
40 END
INPUT STATEMENTS-Illustration l
Solutions
5 CLS
10 REM
40 END
READ Method
values specified).
e.g. READ A
DATA 7
OR
READ A, B, C
DATA 7, 15, 87
it is already given.
Programming Example
Given:
(I) v = t + (u-r)
(ii) W = (u + s3)/t2t2
INPUT STATEMENTS-Illustration I
Solutions
5 CLS
10 REM
15 READt, u, r
30 Let V = (t + (u-r))
40 END
5 CLS
10 REM
15 READ u, s, t
40 END