Note on Statements in QBASIC

  • Note
  • Things to remember
  • Videos
  • Exercise
  • Quiz

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

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

  • 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.
.

Very Short Questions

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

0%
  • A ________ is a set of instructions written by using keywords or commands of QBASIC

    code


    none of the answers are correct


    commands


    statement


  • The _____ statement clears the screen.

    LET


    REM


    DIR


    CLS


  • _________ statement that allows explanatory remarks to be inserted in a program.

    DIR


    REM


    LET


    CLS


  • _______ is an assignment statement used in QBASIC.

    LET
    REM
    PRINT
    CLS
  • ________  statement provides output on the screen.

    CLEAR


    PRINT


    CLS


    REM


  • An electronic shop has announced the following seasonal discount on purchase of Laptop:up to Rs.25000,discount is 0.0% and gift is calculator; Rs.25001-50000,discount is 5.0%, gift is digital note book;Rs.50001-100000,discount is 7.5%,gift is wall clock;Rs. more then 100000,discount 10.0%,gift is wrist watch. Write a program in qbasic based on above criteria to compute and print the net amount to be paid by a customer along with the assured gift.

    solve it to me
  • You scored /6


    Take test again

DISCUSSIONS ABOUT THIS NOTE

You must login to reply

Forum Time Replies Report
Ritesh

WAP to create a quiz book


You must login to reply

sangam

Write a progam to displayKathmanduathmandthmanhmam


You must login to reply

Roji

write a program to get temperature in ceslsius and then display it into fahrenheit .


You must login to reply

Susmee

Wap which asks user two numbers on two lines that calculate sum of the two profucts of the two and two with message.


You must login to reply