Statements in QBASIC

Subject: Computer

Find Your Query
Kaspersky total security

Overview

A statement is a set of instructions written by using keywords or commands of QBASIC. This note provides an information about different statements used in QBASIC.
Statements in QBASIC

A statement (for the QBASIC) is a set of instructions written by using keywords or commands of QBASIC. Every programming language uses keywords as a statement with certain syntax. The keywords have specific meaning in the QBASIC programming. The statements are the first stored in the memory and executed only when the RUN command is given.

Different statements used in QBASIC are as follows:

CLS Statement

The CLS statement clears the screen. If you write CLS statement in the middle of the program then you cannot see the outputs generated before execution of CLS because it clears the screen.
Syntax: CLS

LET Statement

LET is an assignment statement. It is used to assign the value to a variable. LET is an optional statement i.e. without using LET statement one can assign the value to a variable. The data type must match with the variable type otherwise type mismatch error will occur.
Syntax:|LET| variable = value or expression

Scholarships after +2 Abroad Studies Opportunities

Example:
CLS
INPUT " First Number"; A
INPUT "Second Number"; B
let Sum = A+B
PRINT " The Sum is"; S
END

REM Statement

It is a basic declaration statement that allows explanatory remarks to be inserted in a program. The remarks may be useful in a program to explain about different kinds of statements and user defined words. Adding comments in the program allows us to remind about the program and also helps other programmers to understand the logic of the program.
Syntax: REM < Remarks>

Example:
CLS
PRINT "Some text."
REM This text is ignored.
REM This program clears the output screen.
REM and then PRINT " Some text."

PRINT Statement

PRINT statement provides output on the screen. It prints the values of the expression on the screen. If the expression list is blank, no characters are printed. The expressions in the list may be numeric or string. In case of number, the negative number is preceded by a minus sign (-) but in positive number it is preceded by a space.

We can use semicolon and comma with a print statement which results differently than a normal PRINT statement. If expression list ends with comma or semicolon, the next PRINT statement prints on the same line. Comma provides a TAB space, but semicolon provides only one space.
Syntax: PRINT ["Message"]; expression

Example:
CLS
PRINT "Computer is an electronic machine."
PRINT
PRINT "IT's amazing."
PRINT 1000
PRINT " The number is: "; 20
END

Output
Computer is electronic machine
IT's amazing
1000
The number is: 20

Things to remember
  • A statement is a set of instructions written by using keywords or commands of QBASIC. 
  • LET is an assignment statement. It is used to assign the value to a variable.
  • The remarks may be useful in a program to explain about different kinds of statements and user defined words.
  • PRINT statement provides output on the screen. 
  • The CLS statement clears the screen.
  • It includes every relationship which established among the people.
  • There can be more than one community in a society. Community smaller than society.
  • It is a network of social relationships which cannot see or touched.
  • common interests and common objectives are not necessary for society.
Videos for Statements in QBASIC
Clear Screen - QBasic
QBasic Tutorial 2 - Printing Math
QBasic Tutorial 3 - Print Formatting
REM - QBasic
Questions and Answers

A statement (for the QBASIC) is a set of instructions written by using keywords or commands of QBASIC. Some of the examples of statements are CLS, LET etc.

CLS

A=5

B=10

S= A+B

Print " The sum is "; S

END

REM to convert distance in km to m.

CLS
d=5.3
Rem 1km equals to 1000 m

m= d*1000
Print " Distance in Meter ="; m
END

CLS
Input " Enter radius of circlr"; R
A= 3.14*R^2
Print " The area of circle is "; A
END

CLS
Input "Enter the first number "; A
Input " Enter the second number "; B
Avg = (A+B)/2
Print " The average is "; Avg
END

Quiz

© 2019-20 Kullabs. All Rights Reserved.