KnowledgeBoat Logo
OPEN IN APP

Chapter 9 - Unit 2

Fundamentals of QBASIC: Constants and Variables

Class 6 - APC Understanding Computer Studies



Choose the correct option

Question 1

Which of the following is not a valid numeric constant?

  1. -325
  2. -99.99
  3. $24
  4. 0.00025

Answer

$24

Reason — Numeric constants can only consist of numbers (0 - 9) and decimal sign (.). They cannot have a $ sign.

Question 2

Which of the following is a valid string variable?

  1. AB$
  2. AB$$
  3. $AB$
  4. $$AB

Answer

AB$

Reason — String variables must end with a $ sign.

Question 3

Which of the following is a valid string constant?

  1. Computer Science
  2. 'Computer Science'
  3. "Year - 2022"
  4. !!Computer!!

Answer

"Year - 2022"

Reason — String constants are always enclosed in double quotes ("").

Question 4

Which of the following statements is correct for numeric variables?

  1. They cannot store numbers.
  2. They are used for mathematical operations.
  3. They begin with a dollar sign.
  4. They can store string constant.

Answer

They are used for mathematical operations.

Reason — Numeric variables store numbers so they are used for mathematical operations.

Question 5

Which of the following statements is correct in QBASIC?

  1. Negative numbers cannot be assigned to a variable.
  2. Only positive numbers can be assigned to a variable.
  3. Numeric constant can only be assigned to numeric variables.
  4. Numeric variables are assigned to numeric constants.

Answer

Numeric constant can only be assigned to numeric variables.

Reason — Numeric variables are used to store numeric values or numeric constants.

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

A comma is not allowed while writing numeric constants.

State True or 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

Sl.
No.
Column 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

Answer

Sl.
No.
Column 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 the following

Question 1

Two types of variables

Answer

  1. Numeric variables
  2. Alphanumeric variables

Question 2

Two types of constants

Answer

  1. Numeric constants
  2. Alphanumeric constants

Correct the following statements

Question 1

B$ = WORLD CUP 2007

Answer

B$ = "WORLD CUP 2007"

Question 2

"DELHI PUBLIC SCHOOL" = D$

Answer

D$ = "DELHI PUBLIC SCHOOL"

Question 3

$$A = "ARYA PUBLISHING COMPANY"

Answer

A$ = "ARYA PUBLISHING COMPANY"

Question 4

P$ = (A + B)2

Answer

P = (A + B) ^ 2

Question 5

4B$ = "NEW DELHI"

Answer

B4$ = "NEW DELHI"

Question 6

A = 4P + 5Q

Answer

A = 4 * P + 5 * Q

Question 7

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

Answer

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

Question 8

A*B = AB + CD

Answer

AB = A * B + C * D

Write down the appropriate variables for the following

Question 1

_________ = "Understanding Information Technology"

Answer

UIT$ = "Understanding Information Technology"

Question 2

_________ = A * B * C

Answer

Product = A * B * C

Question 3

_________ = "15th August 1947"

Answer

Date$ = "15th August 1947"

Question 4

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

Answer

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

Question 5

_________ = 11.99

Answer

Num = 11.99

Define the following terms

Question 1

Variables

Answer

Variables are the assigned location in the memory used to store a value. This value can be changed at the time of execution of the program. A variable may be a single character or a set of characters. For example: A, B, B10, C$ etc. are some valid variables.

Variables are of two types:

  1. Numeric variables
  2. Alphanumeric variables

Question 2

Constants

Answer

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

Constants are of two types:

  1. Numeric constants
  2. Alphanumeric constants

Question 3

Numeric variables

Answer

Numeric variables are the variables that store integer and fractional (decimal) values. The numeric variables are used to perform all arithmetical operations.
For example, P, A2, N1, etc. are some valid variables.

Question 4

Alphanumeric variables

Answer

Alphanumeric variables are used to store alphanumeric or string constants. The set of characters to be stored must be put within double quotes (" ").
For example, A$, A1$ etc. are some valid alphanumeric variables

Question 5

Alphanumeric constants

Answer

Any set of characters can be called a string or an alphanumeric constant. They also do not change their value at the time of execution of the program. It is a sequence of alphabets, digits and special characters enclosed within double quotes.
For example, "15th AUGUST, 1947", "April 4" etc. are some valid alphanumeric constants.

Question 6

Numeric constants

Answer

Numeric constants are the numbers comprising of digits 0-9. They are positive or negative numbers that may or may not have a decimal point. These constants are used for all kinds of mathematical operations.
For example, 543, -992, 298.543, -29.82, etc. are some valid numeric constants.

Give two differences between

Question 1

Numeric constants and Alphanumeric constants

Answer

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.
For example, 12,54 etc.For example, "NEW DELHI - 110005", "BLOCK 2A" etc.

Question 2

Numeric variables and Alphanumeric variables

Answer

Numeric variablesAlphanumeric variables
Numeric variables store numeric values.Alphanumeric variables store alphabets, words, special characters or their combinations.
These variables must begin with an alphabet, alphabets or alphabets followed by a number.These variables begin with an alphabet or alphabets but must end with a dollar sign.
These variables are used for mathematical operations.Mathematical operations are not possible.
For example, A, ABC, etc.For example, A$, B12$ etc.
PrevNext