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:
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.
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
INPUT " First Number"; A
INPUT "Second Number"; B
let Sum = A+B
PRINT " The Sum is"; S
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>
PRINT "Some text."
REM This text is ignored.
REM This program clears the output screen.
REM and then PRINT " Some text."
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
PRINT "Computer is an electronic machine."
PRINT "IT's amazing."
PRINT " The number is: "; 20
Computer is electronic machine
The number is: 20
What is statement in QBASIC with examples.?
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.
Write a program to find the sum of the numbers.
Print " The sum is "; S
Write a program to convert distance in km to m.
REM to convert distance in km to m.
Rem 1km equals to 1000 m
Print " Distance in Meter ="; m
Write a program to calculate area of a circle.
Input " Enter radius of circlr"; R
Print " The area of circle is "; A
Write a program to find average of any two numbers.
Input "Enter the first number "; A
Input " Enter the second number "; B
Avg = (A+B)/2
Print " The average is "; Avg
© 2019-20 Kullabs. All Rights Reserved.