2. TAXONOMY OF PROGRAMMING
Programming is defined as an art of writing codes.
PROGRAMMER:This is a person that indulges or that is an expert in
writing 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 act upon.
PROGRAMMING LANGUAGE: This indicates the language of choice for
which the programmer communicates with the computer machine.
Bhuwan Bista
3. QBasic
QBasic is a high level programming language. It stands for
Quick Bignners All Perpose Symbolic Instruction Code.
It can be used to create small CUI based application. It
is easier to learn program.
QuickBASIC was originally released in1985
Version 2.0 was released in 1986
In 1966 QBasic 4.5, the last version of QBasic,became
available.
Bhuwan Bista
4. Features of QBasic
It is a user friendly language.
It is widely known and accepted programming language.
It is one of the most flexible language, a modification
can easily be done in already existing program.
Language is easy since the variables can be named
easily and uses simple English phrases with
mathematical expressions.
Bhuwan Bista
5. Basic Terms Related to Programming
• Bug: Error made in program is known as bug.
• Debug: The process of correcting the bug is known as debug.
• Execution: Process of running the program is known as
execution.
• Termination: Process of stoping program is known
as termination
• GIGO: Wrong output generated due to the wrong input.
Bhuwan Bista
6. QBASIC Commands
CLS-Used to clear the screen.
PRINT- Used to display the output on the screen.
REM- Stands for REMARK.It gives an explanation of the program there making the
program more understandable.
LET- Assigns a value to a variable in program.
END-It is usually given at the end of the program.
INPUT-Allows users to enter values for a variable while running a program.
DELETE<LINE NO.>- Delete a line number in a program.
RUN-Used to execute the program and get the output on the screem.
NEW-Used to totally write a new program.
SYSTEM-Used to exit the QBASIC program.
Bhuwan Bista
7. Some Basic Statements
OUTPUT Statement
•These are statements that are used for fetch/retriv
e/show to screen, inputted or stored data from the
computer system.
•The major/basic output statement used in QBasic is
called PRINT.
Bhuwan Bista
8. OUTOUT STATEMENT-Usage & Format
PRINT can be used in two ways e.g.
1. For outputting literals e.g.
PRINT "Hellow_Jitu"
2. For outputting variables (values of an identifier) e.g.
PRINT radius
• (where radius is a variable having a particular value that has
• preciously been inputted/capture, /stirred)
Bhuwan Bista
9. Character Set
•A set of characters that are allowed to use in QBASIC is known
as the QBASIC Character Set.
• The QBASIC Character Set consists of alphabets (both small
and capital), numbers (0 to 9) and special characters.
•QBASIC keywords and variables are formed by using the
characters defined in the QBASIC Character Set.
•These special characters have their own meaning and
function. The table below shows the special characters used
in QBASIC.
Bhuwan Bista
11. CONSTANT
Constants are the data or the values in a program that cannot be
changed during the program execution.
The data may be a letter, words, numbers, or special characters.
A constant can be stored in a variable when it is required to use in
more than one statement or expression.
In QBASIC, these data/constants are grouped into two main
categories. They are:
a. String Constant
b. Numeric Constant
Bhuwan Bista
12. STRING CONSTANT
String Constant is a letter, words, numbers, combination
of letters with numbers or special characters enclosed in
double quotes.
Mathematical operations cannot be performed on
String Constants.
“D”, “BINOD”, “Roll NO. 23”, “!!! Welcome to QBASIC
World !!!”, etc. are some examples of Sting Constants.
Bhuwan Bista
13. Numeric Constant
• Numeric Constant refers to a number.
•A number with or without decimal point is a numeric
constant.
• Thousand separators are not allowed to use in numeric
constant.
• Numeric data should not be enclosed in double quotes.
• Mathematical operations and logical operations can be
performed on the numeric constants.
• 212, 103.03, 540, 31414, etc. are some examples of numeric
constants.
Bhuwan Bista
14. VARIABLES
Variables are the names of memory locations where we store
data.
A value of a variable can be change during the execution of
the program.
There are mainly two types of variables. They are:
1) Numeric Variable
2) String Variable
Bhuwan Bista
15. Numeric Variables
A numeric variable stores numeric data. A numeric variable can be
Integer, Long Integer, Single Precision or Double Precision variables.
• An Integer variable can store only an integer number. Its type
declaration sign is percentage (%).
• A Long integer variable can store a large range of whole number. Its
type declaration sign is ampersand (&0).
• A Single Precision variable can store a whole number as well as
number with decimal. Its type declaration sign is exclamation sign (!).
You can also use it without declaration sign. It is the default numeric
variable.
• A Double Precision variable also stores a whole number as well as
number with decimal point. Its type declaration sign is hash (#). Bhuwan Bista
16. String Variables
• A variable which can store string variable is called String variable. Its
types declaration sign is dollar ($).
• String is a array of character enclosed within the double inverted
comma.
e.g.
N$="ram"
Place$=“Saphal Awasthl“
String Variables are of two types:
1. Variable-Length string
2. Fixed-length string
Bhuwan Bista
17. Rules for naming a variable
1. Variable names can have maximum of 40 characters.
2. Variable names can have alphabets, numbers and decimal point.
3. A Variable name must begin with a letter.
4. A Variable name cannot begin with fn or FN alphabets. For example, fnames$,
fnumetc.
5. Variable names cannot be reserved words.
6. Variable names may be ended with type declaration characters like $, %, &, !,
and #.
Naam$, Address$, Bookname$, GameName$, etc., are examples of Sting Varibales.
Salary!, Age%, Mark, Number1, Number2, FirstNum, RollNumber, etc., are
examples of Numeric Variables.
Bhuwan Bista
18. OPERATOR
•Operators are symbols that indicate the type of operation
QBASIC has to perform on the data or on the values of
variables.
•There are four types of operators in QBASIC. They are:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Sting Operator
Bhuwan Bista
19. Arithmetic Operators
• Arithmetic Operators are used to perform mathematical calculations
like addition, subtraction, division, multiplication and exponential.
• The following table shows arithmetic operators used in QBASIC.
Operation Operator Example Result
Addition + 8+7 15
Subtraction - 5-2 3
Multiplication * 6*2 12
Division / 21/7 3
Integer Division 72 3
Exponential ^ 8^2 64
Modular Division Mod 5Mod2 1
Bhuwan Bista
20. Relational Operators
• Relational Operators are use to perform comparisons on two values of same
type.
• A comparison of sting data with numeric data cannot be done. The comparison of
sting data is done on the basis of ASCII value.
• The result of comparison is either True (non zero) or False (zero).
Operators Name Example
= Equal to A=B
< Less than A<B
> Greater than A>B
<= Less than or Equal to A<=B
>= Greater than or Equal to A>=B
<> Not Equal to A<>B
Bhuwan Bista
21. Logical Operators
Logical Operators combine two or more relational expressions
to evaluate a single value as True (Non Zero) or False (Zero).
The result of evaluation is used to make decisions about the
program flow.
The commonly used logical operators in QBASIC are:
1. AND
2. OR
3. NOT.
Bhuwan Bista
22. AND Operator
• AND operator returns ‘True’ when all the results returned from individual
relational expressions are ‘True’ otherwise it returns ‘False’.
• The AND Truth Table is given shown below.
Condition1(P) Condition2(Q) Result(P and Q)
T--------1 F-------0 F------0
T--------1 T-------1 T------1
F--------0 F------0 F------0
F--------1 T-------1 F------0
Bhuwan Bista
23. OR Operator
• OR Operator return ‘True’ if any one of the relational expressions returns ‘True’.
• If all the relational expressions returns ‘False’ then only the combined result
returned by OR operator will be ‘False’.
Condition1(P) Condition2(Q) Result(P or Q)
T 1 F 0 T 1
T 1 T 1 T 1
F 0 T 1 T 1
F 0 F 0 F 0
Bhuwan Bista
24. NOT Operator
• NOT Operator operates on one operand and returns ‘True’ if the logical operation
returns ‘False’.
• The NOT truth table is as given below.
Condition1(A) Result(Not A)
1 0
0 1
Bhuwan Bista
25. String Operator
•String Operator joins two or more than two sting data.
•The plus sign (+) is used as the String operator.
•The act of combining two stings is called concatenation.
•The following table shows the use of Sting Operator.
String Data1(A$) String Data2(B$) Result(A$+B$)
“Abhay” “Pant” Abhay Pant
“17” “46” 1746
Bhuwan Bista
26. EXPRESSIONS
• An expression is the combination of operators, constants and variables that is
evaluated to get a result.
• The result of the expression is either string data, numeric data or logical value
(true or false) and can be stored in a variable.
• For example, the following are expressions in QBASIC.
a) (A + B) > C
b) A > = B + C
c) u* t + ½*a*t^2
Algebraic Expressions BASIC Expressions
A = L × B A = L * B
P = 2(L + B) P = 2*(L + B)
I = (P × T × R)/100 I = (P * T * R)/100
V = 4/3PiR2 V = 4/3 * PI * R^3
Bhuwan Bista
27. KEYWORD
• Keywords are those words which have special meanings in QBASIC.
• Keywords are formed by using characters of QBASIC Characters Set. Keywords are
statements, commands, functions (built in functions) and names of operators.
• The keywords are also called Reserved Words.
• Some reserved words are:
CLS REM INPUT PRINT FOR
DO SELECT MID$ ASC SQR
LEN LEFT$ TIME$ INT LET…
Bhuwan Bista
28. Syntax
Syntax refers to the set of rules that defines the
combinations of symbols that are considered to be
correctly structured statements or expressions in that
language.
If a user tries to execute a command without proper
syntax, it generates syntax error, usually causing the
program to fail.
Bhuwan Bista