Qbasic: BASIC Stands For Beginners All - Purpose Symbolic Instruction Code
Qbasic: BASIC Stands For Beginners All - Purpose Symbolic Instruction Code
INTRODUCTION
BASIC stands for Beginners All – Purpose Symbolic Instruction code. QBASIC is a
high-level programming language that was developed by Microsoft as a simplified
version of the BASIC programming language. It was released in the 1980s and gained
popularity as a beginner-friendly language for learning programming concepts and
developing simple applications.
QBASIC was widely used in the early days of personal computers and served as an
entry point for many programmers. While it may not be as commonly used today, it still
holds educational value and provides a solid foundation for learning programming
concepts and logical thinking.
Features of QBASIC
It is user-friendly language for beginners to start learning
programming concepts and develop simple applications.
It has a simple and straight forward syntax.
It provides capabilities for drawing shapes, lines, and text on the
screen, as well as playing sounds and music.
It uses an interpreter.
Debugging can be done easily.
Components of QBASIC
COMMANDS/STATEMENTS
Here are some elementary QBASIC commands that are commonly used:
If the user enters the wrong data, an error message "Redo from
Start" will be displayed and the user is allowed to enter the data
again.
Input statement also allows displaying a message to make the
program user friendly and to guide the user to enter correct data.
You can also enter multiple data and multiple variables in one
INPUT statement. In that case the variables must be separated by a
comma and the data entered must also be separated by a comma.
4. LET: Used to assign a value to a variable. Although LET is optional
and can be omitted, it is often included for clarity. For example:
LET x = 10
Mainly, there are two types of control statements in QBASIC. They are:
1) Branching Statement: Branching Statement also further divided into two types:
i) Conditional Branching Statement
IF ... THEN
IF ... THEN ... ELSE
IF ... THEN ... ELSE IF
SELECT CASE
ii) Unconditional Branching Statement
GOTO
2) Looping Statement
i) FOR ... NEXT
ii) WHILE ... WEND
iii) DO LOOP
CLS
INPUT "Enter your marks : "; m
IF m >= 35 THEN PRINT "You are passed !!"
IF m < 35 THEN PRINT "You are failed .."
END
Example 1
CLS
INPUT "Enter your marks "; m
IF m >= 35 THEN
PRINT "You are passed !!"
ELSE
PRINT "You are failed .."
END IF
END
IF [condition] THEN
[statement 1]
ELSEIF
[statement 2]
ELSEIF
[statement n]
........................
.......................
ELSE
[statement n]
END IF
Example 1
CLS
INPUT "Enter your percentage "; p
IF p >= 80 THEN
div$ = "Distinction"
ELSEIF p >= 60 THEN
div$ = "First Divistion"
ELSEIF p >= 40 THEN
div$ = "Second Division"
ELSEIF p >= 35 THEN
div$ = "Third Division"
ELSE
div$ = "Fail"
END IF
PRINT "Division ::: "; div$
END
FOR = TO STEP n
[statements]
NEXT
Example 1
WAP to print the natural numbers from 1 to 10.
CLS
FOR x = 1 TO 10
PRINT x;
NEXT x
END
Example 2
WAP to print even numbers from 1 to 20
CLS
FOR i = 2 TO 20 STEP 2
PRINT i;
NEXT i
END
Example 3
WAP to print your name 10 times
CLS
FOR i = 1 TO 10
PRINT "Your Name"
NEXT i
END
Objective Questions: -
A. Multiple choice questions:
a. This statement is used to terminate or end the program.
i. Input ii. End iii. CLS
b. This command is used to clear the output screen.
i. REM ii. END iii. CLS
c. This command is like a program heading.
i. Input ii. REM iii. END
d. A line number on the QBASIC screen is separated into ______.
i. 2 zones ii. 5 zones iii. 7 zones
e. This variable is used to store a string of characters.
i. Numeric ii. String iii. Constants
B. Fill in the blanks:
a. ___________ are the data values used in a Basic program.
b. ___________ is a version of BASIC.
c. AND/ OR are the _______________ operators.
d. ___________ variable store numeric data.
C. Answer the following questions:
a. What do you understand by QBASIC?
b. Why is QBASIC environment called an IDE?
c. What are constants? Explain how a constant is declared in
QB?
d. What is the importance of QBASIC?
e. What is Input statement? Mention its syntax.
f. What is iteration?
g. How is if else different from if else if statement?
h. Explain the role of step while using for next statement.