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-
- Declaration of variable: – It is one of the stage in which the name of the variable is decided in the Let x
- Initialization of variable: – When the name, value is being decided by the user at the time of creation then it is known as initialization.
Nomenclature of variable
To give the name of the variable certain rules is being followed that is –
- The name of the variable must be alphanumeric in
- The space, symbol is not allowed but underscore can be
- The keywords are not
- The name of the variable goes up to 40 characters
- The name is not case sensitive in nature.
Types of variable
There are three different types of the variable available in Qbasic that is
- 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
- 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
- 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.
- Arithmetical Operator: +,-,*,/,\,^,mod
- Logical Operator: And, Or, Not
- Relational Operator: <,>,<=,>=,=,<>
- Pattern Matching Operator: Is, Like, Eqv, Nor, Xor
In programming environment whenever a user performs the input output operation then to support it different types of statement is used.
- Output Statement: – In QBASIC the “Print” statement is used as output statement. The Print is used for different types of operation, these are –
- To show the message
Print “Welcome to Nalanda College”
- To show the variable value it is used. Let roll=10;
- To show the variable value along with message Let name$=”Ajay”
Print “Name of student=”, name$
- We can perform small level of arithmetical and logical calculation on the data. Let x=5
Let y=10 Print x+y, x*y
- 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
- WAP that accepts two numbers interchange the value of it?
- WAP that accepts length and breadth of rectangle show the area and perimeter of it?
- WAP that accepts distance in KM, convert into meter, centimeter, feet and inch?
- WAP that accepts number of items and their price, give 10% discount then show the net price?
- WAP that show the midpoint of a line?
- WAP that accepts two numbers show the remainder without using remainder operator?
- WAP that accepts any in lower case convert into upper case?
- WAP that accept five numbers, show their sum and average?
- WAP that show the slope value of a line?
- WAP that accept any character show their ASCII value?