Professional Documents
Culture Documents
QBASIC Exercises
QBASIC Exercises
QBASIC Programming
Exercises
1. Answer the following questions
a. What is QBasic programming language?
QBasic stands for Quick Beginners All-purpose Symbolic Instruction Code. It is
a high-level programming language developed by Microsoft for beginners to
learn programming concepts. QBasic provides a simplified syntax and
environment, making it ideal for educational purposes and quick prototyping of
small-scale applications.
b) What are the elements of QBasic?
The elements of QBasic are:
Variables: Used to store data values.
Data Types: Such as integer, floating-point, string, and arrays.
Operators: Including arithmetic, relational, logical, and bitwise operators.
Control Structures: Such as IF-THEN, FOR-NEXT, DO-LOOP for decision
making and looping.
Procedures and Functions: Allow for modular programming by defining
reusable code blocks.
Input/Output Commands: To interact with users and display information on
the screen.
Statements: Including assignment statements, input/output statements, and
control statements.
c) What are the different types of QBasic statements?
various types of QBasic statements are :
Assignment Statements: Assign values to variables.
Input/Output Statements: Read input from the user or display output to the
screen.
Control Statements: Control the flow of program execution, such as IF-
THEN, FOR-NEXT, DO-LOOP.
Subroutine/Function Definition Statements: Define reusable blocks of code.
Error Handling Statements: Handle errors and exceptions during program
execution.
d) What is the extension of QBasic program file? Which key is used to run
QBasic program?
The extension of QBasic program files is typically ".BAS". To run a QBasic
program, F5 key is pressed after writing the code. This command initiates the
compilation and execution process in the QBasic environment.
e) Which operator is used to perform addition in QBasic?
The plus sign (+) is used to perform addition in QBasic, just like in many other
programming languages. For example, a + b would add the values of variables a
and b.
f) What are character set used in QBasic while programming?
In QBasic, the character set used for programming are:
letters from A to Z (both uppercase and lowercase),
numbers from 0 to 9,
punctuation marks(special characters) such as !, @, #, $, and symbols like
&, *, etc.
2. Write a program for the following
a. To calculate the area of four walls of A room
b. Do calculate the area for circle
c. To calculate the volume of a cylinder
d. To calculate the circumference of a circle
e. To calculate the square and cube of the of a given number
f. To calculate the square and cube of the of a given number to calculate
the area and volume of a sphere
REM To calculate the area of four walls of a room. [A=2H(L+B)]
CLS
INPUT "Enter the height of the room: "; H
INPUT "Enter the length of the room: "; L
INPUT "Enter the breadth of the room: "; B
W1 = 2 * H * (L + B)
PRINT "Area of four walls of the room:", W1
END