QBASIC SHORT NOTES

Opearting System

Qbasic

BASIC stands for Beginner’s All Purpose Symbolic Instruction Code. It was invented in 1963, at Dartmouth College, by the mathematicians George Kemeny and Tom Kurtzas

  1. It is a user friendly language.
  2. It is widely known and accepted programming language.
  3. It is one of the most flexible languages, as modification can easily be done in already existing program.
  4. Language is easy since the variables can be named easily and uses simple English phrases with mathematical expressions.

Every programming language has a set of rules that have to be followed while writing a program, following are some rules of QBASIC language :

  1. All QBasic programs are made up of series of statements, which are executed in the order in which they are written.
  2. Every statement should have at least one QBasic command word. The words that BASIC recognizes are called keywords.
  3. All the command words have to be written using some standard rules, which are called “Syntax Rules”. Syntax is the grammar of writing the statement in a language. Syntax Errors are generated when improper syntax is detected

Data is a collection of facts and figures that is entered into the computer through the keyboard. Data is of two types:

  1. CONSTANT :
  2. Data whose value does not change or remains fixed. There are two types of constants:

    1. NUMERIC CONSTANT :
    2. Numbers - negative or positive used for mathematical calculations e.g. −10, 20, 0

    3. ALPHANUMERIC CONSTANT / STRING :
    4. Numbers or alphabets written within double quotes(inverted commas “ “). e.g. “Computer”, “Operating System”

  3. VARIABLE :
  4. Data whose value is not constant and may change due to some calculation during the program execution. It is a location in the computer's memory, which stores the values. Depending on what value is held, Variables are of two types:

    1. NUMERIC VARIABLE :
    2. The variable that holds a Numeric Constant for arithmetic calculations (+, − ,⊸, e.g. A = 50, here A is the Numeric Variable

    3. ALPHANUMERIC VARIABLE :
    4. The variable that holds an Alphanumeric Constant, which cannot be used for arithmetic calculations, is called Alphanumeric Variable or String Variable. An Alphanumeric variable must end with a $ sign and the Alphanumeric constant must be enclosed in inverted commas. e.g. Name$ = “Akanksha”, here Name$ is an Alphanumeric Variable

  1. LIST :
  2. The command is used to list the program on the screen.

  3. RUN :
  4. The command is used to execute the program.

  5. LLIST :
  6. The command is used to list of program as a hardcopy.

  7. LPRINT :
  8. The command is used to get the output of the program on the hard copy.

  9. NEW :
  10. The command is used clear the memory of the existing program.

  11. SYSTEM :
  12. The command is used to take you back to dos prompt.

  13. PRINT and CLS :
  14. command can also be used without a line number. Print is used to view the display on the screen and CLS to clear the screen.

  15. RME :
  16. The command is used to show the position of the mistake.

  17. SAVE :
  18. The keyword is used to save the program. E.g. SAVE “PROGRAM1” QBasic will automatically add a period and an extension “bas” to the filename.

  19. LOAD :
  20. The keyword is used to LOAD the program from the disk to the memory. E.g. LOAD”PROGRAM1”

  1. CLS :
  2. This command is used to clear the screen.

  3. PRINT :
  4. Print command is used to display the output on the screen. E.g. Print “HELLO WORLD!!!

  5. REM :
  6. It stands for Remark. It gives an explanation of the program or of the statements in the program thereby making the program more understandable to the reader. The computer does not execute this statement since whatever is written after REM is ignored by the compiler. REM can be used anywhere and many times in a program.

  7. LET :
  8. It assigns a value to a variable in a program. It stores a value in the memory location.

    SYNTAX : LET<VARIABLE> ⩵< CONSTANT ⁄ VARIABLE or EXPRESSION >

    E.g. Let A = 15…….. Assigning constant to a variable.

    NOTE : A numeric data should be assigned to a Numeric variable and an alphanumeric data to an alphanumeric variable otherwise “TYPE MISMATCH” error is displayed.

  9. END :
  10. This command is usually given at the end of the program. Statements written after end are not executed since the program terminates execution on reading this command.

  11. INPUT :
  12. This statement allows the user to enter a value for the variable while running the program. A question mark (?) appears on the output screen waiting for the user to enter a relevant data and then press enter key. Once the Return key or Enter key is pressed the data is stored in the variable.

    SYNTAX : INPUT < VARIABLE >

    E.g. Input A……Enter Numeric constant

  13. DELETE < LINE NO. >
  14. To delete a line number in a program . e.g. Delete 10 will delete line number 10

    Print with Semi-Colon (;) Semi-colon placed after the message to be displayed, leaves no space between two messages.

    E.g. Print “This is an example” ; ”of QBasic program”

A QBasic program consist of lines containing.

  1. A line number.
  2. A QBASIC keyword like PRINT,END etc.
  3. Each program line begins with positive number.
  4. No two lines should have same number.

~~~~~~~~~~~~~~~~~~~ Thank You ~~~~~~~~~~~~~~~~~~~~~~~~