 # Qbasic Constants Variables and Operators 2020

QBASIC CONSTANTS AND VARIABLES

Here, in this post, we will learn about QBasic constant, QBasic operators and QBasic variables with some examples. the concept of constant, variable, and different operators is very essential for the understanding of any programming language.

Being a beginner you will need the same concept of Qbasic variables and constants and also know about the Qbasic operators to do different mathematical and logical programming in QBasic.

Page Contents

## What are QBasic Constants?

The value that does not change during the time of execution of a program is called Constant.

Constants are of two types:

### 1. Numeric Constants:

Any numeric value, either a real number, positive or negative, or an integer is called a Numeric constant. For example: 124, + 14, 0, – 7.2 are valid numeric constants. These constants are used for calculations, and should not include any special character.

### 2. Alphanumeric or String Constants:

A set of characters is called a String. An alphanumeric or string constant consists of a sequence of alphabet and numerical characters, A – Z, a – z, 0 – 9 and special symbols, like % ? & * ( ) ; # ^ ” ‘ :  / \, etc., which are written enclosed in double-quotes. String constants are used to represent non-numeric quantities, such as names, text, etc.

For example, “SHAM”, “SUM = 44”, “162”, are some valid string constants.

## What is QBasic Variable?

A variable can be defined as a location in the memory, which has been assigned a name and is used to store data temporarily. A variable will continue to hold the value until another value is assigned to it.

There are two types of variables:

### 1. Numeric Variables:

A numeric variable can hold only numeric value. It is represented by an alphabet followed by either another alphabet or a digit. It should not contain any space or symbols, like A, ?, \, /, @, ;, : ,etc. Underscore can be used instead of space. For example, A, B, A3, ABC, A_4, etc., represent numeric variables in QBasic.

### 2. Alphanumeric or String Variables:

A string variable is represented by an alphabet followed by a dollar (\$) sign. It can also contain letters, digits, underscore symbol, and the last character is always a dollar (\$) sign. For example, A1\$, RKL\$, COMPU1\$, etc., are valid qbasic string variables. A string variable can also store string constant in qbasic.

For Example, A2\$ (String Variable) and “tom” (String Constant)

## What is QBASIC Operator?

Operators in Qbasic are use to perform different mathematical, logical and comparison operations.

There are three types of operators in QBasic:

### 1. Arithmetic Operators:

A computer performs many arithmetic operations and calculations with the help of arithmetic operators. The basic arithmetic operators use in QBasic are given in the following table: ### 2. Relational Operators

These operators are used to compare two values using any of the given relational operators. This can be called a QBasic comparison operator. Below is an image of all the qbasic relational operators: ### 3. Logical Operators

Logical operators in QBasic are used to perform logical operations on numeric values. QBasic Logical operators are used to combine two or more relational expressions and return a single value as TRUE or FALSE in a decision. The logical operators are: AND, OR, NOT.

Below is an image of all  the QBasic logical operators: ## HIERARCHY OF OPERATIONS in QBASIC

The hierarchy defines the order in which the operators are executed in any Qbasic expression. It uses BEDMAS rule for the hierarchy of operation. STEPS OF SOLVING

1. First, the bracket will be solved.
2. Then, the exponentiation will be performed.
3. Now multiplication and division will be performed.
4. Now, addition and subtraction will be performed.

Check the numerical expression below to know how it was solved using the BEDMAS rule in QBasic.

12*4+(14+4)+2^2-12/6   #the bracket will be solved.

12*4+18+2^2-12/6          #the exponentiation will be performed.

12*4+18+4-12/6               #multiplication and division will be performed.

70-2                                   #subtraction will be performed

68

Once you understand the basic concept of qbasic constants, variables, and operators, do check about “what are qbasic QB64 statements and commands?“. These qbasic statements and commands will help you to write QBasic programs using the built-in qbasic programming syntax.

And here is a list of simple Qbasic Programming Examples and Exercises that will help you write simple mathematical programs.

## What are arithmetic operators in Qbasic programming?

A computer performs many arithmetic operations and calculations with the help of arithmetic operators.

## What are logical operators in Qbasic?

Logical operators are used to perform logical operations on numeric values. QBasic Logical operators are used to combine two or more relational expressions and return a single value as TRUE or FALSE in a decision. The logical operators are: AND, OR, NOT.

## What do u mean by variable?

A variable can be defined as a location in the memory, which has been assigned a name and is used to store data temporarily. A variable will continue to hold the value until another value is assigned to it.

## What are relational operators in basic?

These operators are used to compare two values using any of the given relational operators. This can be called a QBasic comparison operator.

Scroll to Top