Monday, 19 September 2016

QBASIC COMMANDS

1. CLS - This command is used to clear the screen.   

2. PRINT - Print command is used to display the output on the screen.           

 E.g.  Print “HELLO WORLD!!!” 
          Print 80 * 8 
          Print – Only Print command will leave blank space. 
          Print Tab(10) ”Abhijeet” – will print Abhijeet on 10 column. 

3. REM - 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.  

4. LET - 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 
      Let A = B……….........Assigning variable to a variable 
      Let C = A + B…........ Assigning an expression to a variable 

Using Let with Numeric Variables:  Let A = 50, here A is a Numeric Variable and ‘50’ is a Numeric Constant and value ‘50’ is assigned to A and stored in the computer’s memory for further calculations. 

Using Let with Alphanumeric Variable: Let N$ = “QBasic Program”, here N$ is an Alphanumeric Variable and “QBasic Program” is the Alphanumeric Constant assigned to N$.  

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. 

5. END - 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. 

6. INPUT - 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 
        Input N$…...Enter Alphanumeric constant 

Input “Enter name:”;N$….Giving relevant message to avoid erroneous  data input 

7. DELETE <LINE NO.> - To delete a line number in a program .
 E.g. Delete 10 will delete line number 10 
         Delete 30-50 will delete all line numbers between 30 to 50. 

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” 
output:  This is an example of QBasic program 

Print with Comma( , ):  The screen of the computer is made of 80 columns and 40 rows.  The columns are divided into five (5) zones of 14 columns each.  Comma placed after the message prints the message zone wise on the screen.   

No comments:
Write comments