ProgrammingBasic
QBASIC
Qbasic Programming Examples and Exercises
By Izzaz September 16, 2023
In this article, we will learn about QBasic examples and exercises for class 6 and class 7
standards.
Qbasic sample example programs for beginners. In this post, we will see and learn
some QBasic programming examples and do some simple exercises to understand how
it works.
Table of Contents
Examples of some Qbasic Programming Examples and
Exercises
Write a Qbasic program to enter your name and print it.
Write a Qbasic program to enter name, country, city, and age and print them.
Write a program to find the area of a rectangle in Qbasic.
Write a program to find the area of the triangle.
Write a Qbasic program to find the area of the circle.
Write a program to find the area of the square.
Write a Qbasic program to find the volume of the box.
Write a Qbasic program to find the circumference of the circle.
Write a program to find out the Simple Interest.
Write a program to find out the simple Interest and the Amount.
Update: More Qbasic Examples
This post has beginner-level Qbasic examples and exercises that will help you to
understand the concept of variable and Qbasic statements like INPUT, PRINT, CLS, etc
Before getting started it is important to know the basic Qbasic statements or QBasic
commands first.
Read more about it, check: – QBasic Commands and Statements-2020
Here, we will code and learn some simple examples that are easy to understand for class
6/ class 7 students, who have started with QBasic programming.
Here, the program codes are explained with their formulas to help you understand them
better.
Examples of some Qbasic Programming Examples
and
Exercises
EXAMPLE 1:
Write a Qbasic program to enter your name and print it.
CLS
INPUT ‘Enter your name’;n$
PRINT ‘The name is’;n$
END
Here since the input data is a string then the variable name ( n ) in which it is to be stored
is written after INPUT command followed by $ sign( n$ ).
EXAMPLE 2:
Write a Qbasic program to enter name, country, city, and age
and print them.
CLS
INPUT ” Enter the name “;N$
INPUT ” Enter the city”;C$
INPUT ” Enter the country”;CO$
INPUT ” Enter the age”;A
PRINT ” The name is “;N$
PRINT ” The city is “;C$
PRINT ” The country is “;CO$
PRINT ” The age is “;A
END
Since the entered value of name, city, and country is a string so we write the variable
name with a $(dollar sign) before them, and since age is a number so the variable name
is written directly.
Example 3:
Write a program to find the area of a rectangle in Qbasic.
FORMULA: Area of a Rectangle is length x breadth. Here length is variable l and
breadth is variable b. And is the variable to store the value of the result and print it as
output.
CLS
INPUT ” Enter the length ” ;l
INPUT ” Enter the breadth ” ;b
LET A = l*b
PRINT” The area of rectangle=” ;a
END
Example 4:
Write a program to find the area of the triangle.
FORMULA: Area of triangle is ½ x base x height.
Here variable b is the base and h is the height. T is the variable to store the result and
print it.
CLS
INPUT ” Enter the base” ;b
INPUT ” Enter the height” ;h
LET T = 1/2*b*h
PRINT” The area of triangle=” ;T
END
Example 5:
Write a Qbasic program to find the area of the circle.
FORMULA : Area of a circle is 22/7 x radius^2. Here we use variable R as Radius.
And C is the variable where we store the result.
CLS
INPUT” Enter the radius ” ;R
LET C=22/7*R^2
PRINT ” The area of circle =” ;C
END
Example 6:
Write a program to find the area of the square.
FORMULA: Area of a square is = Side2 square units. Here the result is stored in
variable “square”.
CLS
INPUT” Enter the number” ;n
LET square= n^2
PRINT” The area of square=” ;Square
END
Example 7:
Write a Qbasic program to find the volume of the box.
FORMULA: Area of a box = length x breadth x height.
The variable are l, b , and h for length, breadth and height and the result will be stored in
the variable volume.
CLS
INPUT ” Enter length ” ;l
INPUT ” Enter breadth ” ;b
INPUT ” Enter height ” ;h
LET vol= l*b*h
PRINT” The volume of box is =” ;vol
END
Example 8:
Write a Qbasic program to find the circumference of the circle.
FORMULA : Formula of circumference = 22/7 x Radius x 2
CLS
INPUT” Enter the radius ” ;R
LET Circumference=22/7*R*2
PRINT ” The area of circle =” ;Circumference
END
Example 9:
Write a program to find out the Simple Interest.
FORMULA : Simple Interest = Principle x Rate x Time / 100
CLS
INPUT ” Enter the Principal”;P
INPUT ” Enter the Rate”;R
INPUT ” Enter the Time”;T
LET I = P*T*R/100
PRINT ” The simple Interest = “;I
END
Example 10:
Write a program to find out the simple Interest and the
Amount.
FORMULA : Formula of Simple Interest = Principle x Rate x Time / 100
Amount = Principle + Simple Interest
CLS
INPUT ” Enter the Principal”;P
INPUT ” Enter the Rate”;R
INPUT ” Enter the Time”;T
LET I = P*T*R/100
LET A= P + I
PRINT ” The simple Interest = “;I
PRINT ” The amount=”;A
END
Update: More Qbasic Examples
GET MORE QBASIC EXAMPLES AND EXERCISE IN QBAISC EXAMPLES
So, these are some common Qbasic programming examples that are useful for students
and new programmers. These posts will be updated frequently with new Qbasic
examples and exercises, so keep visiting for more fun programming exercises.
PREVIOUS NEXT
Qbasic Color statement QBasic Commands and Statements-2023
Search
Search
Recent Posts
How to merge JSON files in python
Top 40 Git commands with Examples
Check GitHub Account in the Terminal
Install Tailwind CSS in Vue 3 and Vite App
How to Install Pip(pip3) in Ubuntu Linux 22.04
Categories
CSS
JavaScript
Nuxt
Python
QBasic
Quick Fix
ReactJs
Svelte
Uncategorized
Vue
About Us Blogs
Categories
Contact Us
Disclaimer