Structure, constant and variable of QBASIC

Structure, constant and variable of QBASIC

Published by: BhumiRaj Timalsina

Published date: 16 Jan 2022

Structure, constant and variable of QBASIC, Grade-9, Reference Note

QBASIC is the most popular high level programming language. Various versions of BASIC have been developed by Microsoft Company. This language is quite simple to understand and has been adopted by most of the microcomputers. It is suitable for both mathematical and business problems. It is compatible with MSDOS environment and it has two basic files QBASIC.EXE and QBASIC.HLP. We can edit, debug and execute the program using these two files.

The advantages of QBASIC

  1. QBASIC is easy to learn and fun to practice. It may be called a "People's language".
  2. It is available almost in every computer from micro to mainframe. Therefore, a program developed in a micro can run on bigger system with minor modifications.
  3. It is suitable for mathematical and business application.
  4. Program development cycle is quick, debugging is simple, and
  5. Modification of program is quite easy.

Starting QBASIC

It occupies very low memory so it may be possible to run the system using floppy disk also. It is compatible with MS-DOS and have only two files QBASIC.EXE and QBASIC.HLP

Steps

  1. Get MS-DOS System and MS-DOS Prompt
    C:\>
  2. Change the Directory
    C:\>CD QBASIC
    C:\QBASIC>
  3. Type QBASIC and press Enter
    C:\QBASIC>QBASIC enter

When you are working with Windows system. Open QBASIC Folder on Windows.

Double click over the QBASIC.EXE icon. We will get the QBASIC System as below. Press ESC key and get the programming window of the QBASIC and type the program on the working of QBASIC.

Structure of Basic

To construct the QBASIC program we have to arrange some standard elements.

The elements are:

The Character Set

QBASIC has the character set consisting of the following elements:

  1. Alphabets: A, B, C,....Z
  2. Digits: 0, 1, 2........,9 and
  3. Special characters: + - * / ( ) . , $ ; ,: ,= ,> ,< , ^

The symbol ^ (caret) is used to denote exponentiation operator, the symbol * (asterisk) is used to denote multiplication and other symbols; have their usual meanings.

Constants and Variables

A quantity in a computer program which does not change its value during the execution of the program is called a constant and the quantity which may change its values during the execution of the program is called variable. QBASIC allows the following constants:

  • Numeric constant

    Numeric constant is one that is formed by a sequence of digits 0, 1, 2,.....9 and may include a decimal point. A numeric constant known as number may be integer or a real number. 383, +57, 0, -6.2 and 6.15E4 are valid numeric constants. The number 6.15E4, in fact represent 6.15 * 104. The notation E is used to represent exponential form. The number after E is the exponent which can be positive or negative. However, its length cannot exceed two digits.

    It is also important to keep in mind that

    • QBASIC does not distinguish between an integer and fraction.
    • Commands are not allowed in a numeric constant.
    • The limit on the number of digits that can be used varies from computer to computer. Normally, a numeric constant can have up to a maximum of eight digits.
  • String constant

    A string constantconsists of a sequence of characters which must be enclosed by a quotation mark.

    In QBASIC, variables are also of two types:

    1. Numeric variable :Numeric variable can assume numeric value and is represented by an alphabet or an alphabet followed by another alphabet or digit. For example A, C, A2, ABC, A6etc, represent numeric variables.
    2. String variable : A string variable is represented by an alphabet followed by dollar ()sign.Itshouldbekeptinmindthatwhileconstructingthestringvariable,dollar()sign.Itshouldbekeptinmindthatwhileconstructingthestringvariable,dollar() should be the last character. For example B1,NAME,NAME, BOOK1$, etc are valid string variables.