In programming environment the variable is nothing but a location where the value being stored for different types of operation. The value of the variable can be changed during the program execution more than one time. The type and size of the value in the variable is determined by the data type that a user uses for it.

“The variable is memory location where certain value is being stored for different types of calculation in the program and stores the final result.”

Stages of variable

There are two different stages of the variable, that is-


  1. Declaration of variable: – It is one of the stage in which the name of the variable is decided in the Let x
  2. Initialization of variable: – When the name, value is being decided by the user at the time of creation then it is known as initialization.

Let roll=10

Nomenclature of variable

To give the name of the variable certain rules is being followed that is –

  1. The name of the variable must be alphanumeric in
  2. The space, symbol is not allowed but underscore can be
  3. The keywords are not
  4. The name of the variable goes up to 40 characters
  5. The name is not case sensitive in nature.


Types of variable

There are three different types of the variable available in Qbasic that is


  1. Global variable: – The variable that is created at the top of the program is known as global variable. The global variable can be used anywhere in the program and its life ends whenever the execution of the program
  2. Local variable: – The variable that is created within the program construct body is known as local variable. The scope of the local variable is only within the body of the program construct and its life ends whenever the control of program execution came out from the body of the program
  3. Formal Variable: – The variable that is created in the parenthesis of the function is known as formal variable. The scope and life time of formal variable is equal to the local variable. The scope is within the body of the function and life ends when the function execution



In the QBASIC programming environment when the expression is written then the symbol that is used along with operand is known as operator. The working of operator is defined inside the translator of the language.

“The operator is the symbolic structure that is used to write an expression within the program through which different types of calculations can be performed.”

The operator when executes then it return either Boolean or numeric value. There are different types of operator available in QBASIC.

  1. Arithmetical Operator: +,-,*,/,\,^,mod
  2. Logical Operator: And, Or, Not
  3. Relational Operator: <,>,<=,>=,=,<>
  4. Pattern Matching Operator: Is, Like, Eqv, Nor, Xor



Input-output Statement

In programming environment whenever a user performs the input output operation then to support it different types of statement is used.

  1. Output Statement: – In QBASIC the “Print” statement is used as output statement. The Print is used for different types of operation, these are –
    1. To show the message


Print “Welcome to Nalanda College”


  1. To show the variable value it is used. Let roll=10;

Print roll

  1. To show the variable value along with message Let name$=”Ajay”

Print “Name of student=”, name$

  1. We can perform small level of arithmetical and logical calculation on the data. Let x=5

Let y=10 Print x+y, x*y

  1. Input Statement: – The user can make within the variable for calculation, so the “Input statement is used to do

Print “Enter the roll” Input roll


4In QBASIC both the input and output as message operation can be performed by the user using “Input” statement.

Input “Enter the roll:”, roll



Question To Solve

  1. WAP that accepts two numbers interchange the value of it?
  2. WAP that accepts length and breadth of rectangle show the area and perimeter of it?
  3. WAP that accepts distance in KM, convert into meter, centimeter, feet and inch?
  4. WAP that accepts number of items and their price, give 10% discount then show the net price?
  5. WAP that show the midpoint of a line?
  6. WAP that accepts two numbers show the remainder without using remainder operator?
  7. WAP that accepts any in lower case convert into upper case?
  8. WAP that accept five numbers, show their sum and average?
  9. WAP that show the slope value of a line?
  10. WAP that accept any character show their ASCII value?

Leave a reply

Please enter your comment!
Please enter your name here