Friday 13 January 2023

QBasic Program

 

Writing QBasic Program 

========================================================================


QBASIC Statements:

 Any command or the instructions in the QBASIC is called a statement. Statements are classified into executable and non-executable. Executable statement specify actions and non-executable statements specify characteristics, arrangements and initial values of data.

Some of the QBASIC statements are:

 

CLS

REM

INPUT

LET

PRINT

END

 =====================================================

1. CLS statement:

 

This statement is used to clear the output screen. Generally it is used at the starting of the program.It clears the previous output from the display screen and makes the screen blank.

 Syntax: CLS

--------------------------------------------------------------------------------------------- 

 

2. REM statement:

 

This statement is used to put comments in the program. REM or Remarks is non-executable statement where single quotation(‘) is used.

 Syntax: REM <remark>

--------------------------------------------------------------------------------------------- 

 

3. INPUT statement:

 

The INPUT statement is used to accept data from the keyboard at the program execution time. It receives input from the keyboard during the execution of the program.

 Syntax: INPUT [“Message”] ; Variable

---------------------------------------------------------------------------------------------

 

 4. LET statement:

 

It is an an assignment statement which is used to assign value to a variable. LET is an optional statement.

 Syntax: LET [variable] = [expression]

 ---------------------------------------------------------------------------------------------

 

5. PRINT statement:

 

It is used to display the output on the screen. Question mark (?) also can be used instead of PRINT command to display on the screen.

 Syntax: PRINT[expression][{; | ,}]

---------------------------------------------------------------------------------------------

 6. END statement:

 

END statement is used to terminate the execution of the program. It stops the further processing of the program.

 Syntax: END

---------------------------------------------------------------------------------------------

 *************************************************************


QBasic Program 


Multiplication calculator.
===================
Cls
Input "Enter the first number: ", A
Input "Enter the second number: ", B
Print "The answer is: "; A * B
***********************************************


 Addition calculator.
===================
Cls
Input "Enter the first number: ", A
Input "Enter the second number: ", B
Print "The answer is: "; A + B
***********************************************


 Division calculator.
===================
Cls
Input "Enter the first number: ", A2
Input "Enter the second number: ", B
Print "The answer is: "; A / B
***********************************************


Subtraction calculator.
===================
Cls
Input "Enter the first number: ", A
Input "Enter the second number: ", B
Print "The answer is: "; A - B
***********************************************



No comments:

Post a Comment