# Fundamentals of QBASIC: Constants and Variables

## Fill in the blanks

#### Question 1

Alphanumeric variables always end with a dollar (\$) sign.

#### Question 2

Numeric constants include only numbers.

#### Question 3

The maximum length of a variable is 12.

#### Question 4

Alphanumeric constants are always enclosed in double quotes.

#### Question 5

Variables always begin with alphabets.

#### Question 6

Comma is not allowed while writing numeric constants.

## State whether the following statements are True/False

#### Question 1

A45 is a valid numeric variable.
True

#### Question 2

A+B is not a valid alphanumeric variable.
True

#### Question 3

Special characters are used in variables.
False

#### Question 4

Numeric constants are stored in numeric variables.
True

#### Question 5

0.5495 is a valid numeric constant.
True

#### Question 6

Decimals are not allowed in numeric constants.
False

## Match the following

#### Question 1

S. NoColumn 1Column 2
1Numeric constantsAlphanumeric constants
2Alphanumeric variables representare always enclosed in " "
3Alphanumeric constantsmust begin with an alphabet
4A variableString variables
5Alphanumeric variables are calledcan take part in mathematical operations

S. NoColumn 1Column 2
1Numeric constantscan take part in mathematical operations
2Alphanumeric variables representAlphanumeric constants
3Alphanumeric constantsare always enclosed in " "
4A variablemust begin with an alphabet
5Alphanumeric variables are calledString variables

## Name them

#### Question 1

Two types of variables

1. Numeric variables
2. Alphanumeric variables

#### Question 2

Two types of constants

1. Numeric constants
2. Alphanumeric constants

## Correct the following expressions

#### Question 1

B\$ = WORLD CUP 2007

B\$ = "WORLD CUP 2007"

#### Question 2

"DELHI PUBLIC SCHOOL" = D\$

D\$ = "DELHI PUBLIC SCHOOL"

#### Question 3

\$\$A = "ARYA PUBLISHING COMPANY"

A\$ = "ARYA PUBLISHING COMPANY"

P\$ = (A + B)2

P = (A + B) ^ 2

#### Question 5

4B\$ = "NEW DELHI"

B4\$ = "NEW DELHI"

#### Question 6

A = 4P + 5Q

A = 4 * P + 5 * Q

#### Question 7

AVG = (2A + 3B + 4C)/3

AVG = (2 * A + 3 * B + 4 * C) / 3

#### Question 8

A*B = AB + CD

AB = A * B + C * D

## Write down the appropriate variables for the following

#### Question 1

_________ = "Understanding Information Technology"

UIT\$ = "Understanding Information Technology"

#### Question 2

_________ = A * B * C

Product = A * B * C

#### Question 3

_________ = "15th August 1947"

Date\$ = "15th August 1947"

#### Question 4

_________ = 1/2 * A + 1/4 * B

Ans = 1/2 * A + 1/4 * B

#### Question 5

_________ = 11.99

Num = 11.99

## Define the following terms

#### Question 1

Variables

Variables change their values at the time of execution. A variable may be a single character or a set of characters.
For example: A, B, B10, C\$ etc.

#### Question 2

Constants

Constants are data items, the values of which do not change at the time of execution of the program.
For example: 76, -43, "Hello", etc.

#### Question 3

Numeric variables

These are the variables which can store numbers or numeric values. They can also store integer and real type numeric values.
For example: A = 45.

#### Question 4

Alphanumeric variables

These variables are used to store alphabets, words and special characters or their combinations. The set of characters to be stored must be put within double quotes (" ").
For example: A\$ = "Hello".

#### Question 5

Alphanumeric constants

Any set of characters enclosed within double quotes (" ") can be called an alphanumeric constant. They do not change their value at the time of execution of the program.
For example: "Rishi", "April 4".

#### Question 6

Numeric constants

Numeric constants are the constants comprising of the digits. They may be accompanied by a negative sign or a decimal point. These constants are used for all kinds of mathematical operations.
For example: 56, -43, 7.43, -5.32 etc.

## Give two differences between

#### Question 1

Numeric constants and Alphanumeric constants

Numeric constantsAlphanumeric constants
Numeric constants comprise of digits.Alphanumeric constants comprise of a set of characters.
Numeric constants are not enclosed in double quotes.Alphanumeric constants are enclosed in double quotes.

#### Question 2

Numeric variables and Alphanumeric variables