KnowledgeBoat Logo
OPEN IN APP

Chapter 9 - Unit 3

Fundamentals of QBASIC: Commands and Statements

Class 6 - APC Understanding Computer Studies


Fill in the blanks

Question 1

The full form of QBASIC is Quick Beginner's All-Purpose Symbolic Instruction Code.

Question 2

LET statement is used to assign a value to a variable.

Question 3

The term used to correct errors in a program is called debugging.

Question 4

F5 function key is used to execute a program in QBASIC.

Question 5

REM is a non-executable statement.

Question 6

The extension of BASIC program file is .bas.

Question 7

The maximum number of characters in the primary name of a BASIC file is eight.

Question 8

Using EXIT command, you can quit QBASIC and return to the desktop.

Question 9

Statements are the set of instructions to a program.

Question 10

Save As option is used to store a program in the secondary memory for the future use.

Correct the errors

Question 1

CLEAR
LET A = 15
TAKE B = 10
P = (A + B)2
DISPLAY P
END

Answer

CLS
LET A = 15
LET B = 10
P = (A + B) ^ 2
PRINT P
END

Question 2

CLS
INPUT A = 10
LET B = 45
P = (A x B) / 5 + B
PRINT P
STOP

Answer

CLS
LET A = 10
LET B = 45
P = (A * B) / 5 + B
PRINT P
END

Explain the meaning of the following commands/statements with reference to QBASIC

Question 1

New Program

Answer

It allows the user to clear the working memory for fresh storage of the next program.

Question 2

Open Program

Answer

It allows the user to open an existing program which is already stored in the main memory of the computer.

Question 3

Save As

Answer

It allows the user to save the current program in the computer's memory for future use.

Question 4

Print

Answer

It allows the user to get a hard copy of the current program.

Question 5

Exit

Answer

It allows the user to quit QBASIC and return to the desktop.

Write short notes on

Question 1

RUN

Answer

This command is used in QBASIC to execute any program or to see the output of the program. This can also be done by pressing F5, a function key. The output of the program is displayed on the output screen.

Question 2

CLS

Answer

CLS means to clear the content of the program and the output screen. This command is used at the beginning of the program. It allows the user to study the desired output of the program.

Question 3

LET

Answer

LET statement is used to assign a value to a variable. This statement can be used to assign a numeric or string constant to a variable.

Syntax-
LET <variable> = <constant or variable or expression>

Question 4

REM

Answer

REM statement is used to write remarks about any program which basically shows the purpose of a program. It is a non-executable statement. Hence, the computer will ignore the content of the REM statement at the time of execution and the content will go to the next line.

Syntax:
REM <comment about the program>

Question 5

PRINT

Answer

PRINT statement is used to display any data, value, or message on the screen. PRINT statement may be used with or without a variable.
For example-
PRINT "HELLO"
PRINT A, B

Write down all the steps to perform the following tasks in QBASIC

Question 1

Write a new program

Answer

To write a new program, follow these steps:

Step 1: Click 'QBASIC' icon. The QBASIC window opens. Otherwise, select a path and open QBASIC window.

Step 2: Press 'ESC' key to clear the contents of the screen.

Step 3: Select the 'File' menu and click the option 'New Program'.

The QBASIC screen will be ready to write the program.

Question 2

Save a program

Answer

To save a program, follow these steps:

Step 1: Click 'File' and select 'Save As' from the drop-down menu.

Step 2: The 'Save As' window appears on the screen. Select a directory/drive from the box.

Step 3: Write the file name in the 'File Name' box.

Step 4: Click 'OK'.

The file will be saved in the desired location.

Question 3

Get the hard copy of a program

Answer

To get the hard copy of a program, follow these steps:

Step 1: Open the program whose hard copy is required.

Step 2: Click 'File' and select 'Print' option from the drop down menu. Print window will appear.

Step 3: Select the printer, page layout, number of copies required etc. and click 'Print' option.

The program will be printed.

Question 4

Save the current program

Answer

To save the current program, follow these steps:

Step 1: Click 'File' and select 'Save As' from the drop down menu.

Step 2: The 'Save As' window appears on the screen. Select a directory/drive from the box.

Step 3: Write the file name in the 'File name' box.

Step 4: Click 'OK'.

The file will be saved at the destination with the given name.

Question 5

Quit QBASIC platform

Answer

To quit QBASIC platform, follow these steps:

Step 1: Click 'File' and select 'Exit' from the drop down menu.

Step 2: Press 'Enter' key.

Step 3: If you have made any changes to the current program, the system will ask for confirmation from the user. Click 'Yes', 'No' or 'Cancel' according to your need.

QBASIC platform will close and return to the Windows.

Distinguish between

Question 1

RUN and PRINT

Answer

RUNPRINT
This command is used in QBASIC to execute a program or to see the output of the program.This command is used to display any data, value or message on the screen.

Question 2

Program Screen and Output Screen

Answer

Program ScreenOutput Screen
Program screen is used for writing or editing a program.Output screen shows the output of a program when the program is run.

Solutions to Unsolved Programs on LET & PRINT

Question 1

Write a program in QBASIC to greet your friend on the occasion of New Year by using PRINT statement. The output of the program is shown as:

Season's Greeting  
Best Wishes for  
A Happy and Prosperous New Year   
From:  
Name:   
Solution
PRINT "Season's Greeting"
PRINT "Best Wishes for"
PRINT "A Happy and Prosperous New Year"
PRINT "From:"
PRINT "Name: KnowledgeBoat"
Output
Season's Greeting
Best Wishes for
A Happy and Prosperous New Year
From:
Name: KnowledgeBoat

Question 2

There are 28 boys and 22 girls in your class. Write a program in QBASIC to find the percentage of boys and girls in the class.

Solution
Cls
Let B = 28
Let G = 22
Let T = B + G
Let PERB = B / T * 100
Let PERG = G / T * 100
Print "PERCENTAGE OF BOYS= "; PERB
Print "PERCENTAGE OF GIRLS= "; PERG
End
Output
PERCENTAGE OF BOYS= 56
PERCENTAGE OF GIRLS= 44

Question 3

The base and height of a triangle are 15 cm and 10 cm respectively. Write a program in QBASIC to calculate the area of the triangle.
(Hint: Area of a triangle = 1 / 2 * base * height)

Solution
Cls
Let B = 15
Let H = 10
Let A = 1 / 2 * B * H
Print "AREA OF THE TRIANGLE= "; A; "SQ CM"
End
Output
AREA OF THE TRIANGLE= 75 SQ CM

Question 4

A salesman sold 14 chairs at the rate of ₹ 275 each and 3 tables at the rate of ₹ 650 each. Write a program in QBASIC to calculate the total sale.

Solution
Cls
Let C = 14
Let COSTC = C * 275
Let T = 3
Let COSTT = T * 650
Let TOTAL = COSTC + COSTT
Print "TOTAL SALE= Rs. "; TOTAL
END
Output
TOTAL SALE = Rs. 5800

Question 5

Write a program in QBASIC to calculate the area and circumference of a circle of the radius 14 cm.
(Hint: Area of a circle = 22/7 * r2, Circumference = 2 * 22/7 * r)

Solution
Cls
Let R = 14
Let A = 22 / 7 * R * R
Let C = 2 * 22 / 7 * R
Print "AREA= "; A; "SQ CM"
Print "CIRCUMFERENCE= "; C; "CM"
End
Output
AREA = 616 SQ CM
CIRCUMFERENCE = 88 CM 

Home Assignment

Question 1

Write a program in QBASIC to find the value of the given expressions when a = 10, b = 5, c = 2.

  1. a2 +b3 +c4
  2. (a + b)2
  3. a2 + b2
  4. (a - b + c)2
Solution
Cls
Let A = 10
Let B = 5
Let C = 2
Let EXP1 = A * A + B * B * B + C * C * C * C
Let EXP2 = (A + B) ^ 2
Let EXP3 = A * A + B * B
Let EXP4 = (A - B + C) ^ 2
Print "ANSWER OF EXPRESSION 1= "; EXP1
Print "ANSWER OF EXPRESSION 2= "; EXP2
Print "ANSWER OF EXPRESSION 3= "; EXP3
Print "ANSWER OF EXPRESSION 4= "; EXP4
END
Output
ANSWER OF EXPRESSION 1= 241
ANSWER OF EXPRESSION 2= 225
ANSWER OF EXPRESSION 3= 125
ANSWER OF EXPRESSION 4= 49

Question 2

In a class of 60 students, 90% are present. Write a program in QBASIC to calculate the number of students present and absent.

Solution
Cls
Let T = 60
Let PRESENT = 90 / 100 * 60
Let ABSENT = T - PRESENT
Print "STUDENTS PRESENT= "; PRESENT
Print "STUDENTS ABSENT= "; ABSENT
END
Output
STUDENTS PRESENT= 54
STUDENTS ABSENT= 6

Question 3

The rate of petrol is ₹ 47.60 per litre. You paid ₹ 250 to the pump attendant and asked for 5 litres of petrol to be filled in the tank. Write a program in QBASIC to calculate the cost of petrol and the amount of money refunded.

Solution
Cls
Let RATE = 47.6
Let COST = 5 * RATE
Let PAID = 250
Let REFUND = PAID - COST
Print "MONEY REFUNDED = Rs. "; REFUND
END
Output
MONEY REFUNDED = Rs. 12

Question 4

In a book fair, you purchased the following books:

Harry Potter Books : ₹ 950
English Dictionary : ₹ 1200
Encyclopedia : ₹ 1600

You gave an amount of ₹ 4000 to the shopkeeper. Write a program in QBASIC to calculate the total amount to be paid to the shopkeeper and the money refunded by him.

Solution
Cls
Let HPB = 950
Let ED = 1200
Let EN = 1600
Let TOTAL = HPB + ED + EN
Let AMT = 4000
Let REFUND = AMT - TOTAL
Print "TOTAL MONEY TO BE PAID = Rs. "; TOTAL
Print "REFUND = Rs. "; REFUND
End
Output
TOTAL MONEY TO BE PAID = Rs. 3750
REFUND = Rs. 250

Question 5

'LEXPO' announces 25% discount on all leather items. You purchased a leather bag that costs ₹ 660 and a belt priced ₹ 160. Write a program in QBASIC to calculate the amount to be paid to the shopkeeper.

Solution
Cls
Let LB = 660
Let B = 160
Let TOTAL = LB + B
Let DISC = 25 / 100 * TOTAL
Let AMT = TOTAL - DISC
Print "AMOUNT TO BE PAID = Rs. "; AMT
End
Output
AMOUNT TO BE PAID = Rs. 615
PrevNext