Chapter 10 QB64 – Programming Statements
A.
1. False
2. False
3. True
4. False
5. True
B.
1. N=7
2. PRINT 4-2
3. PRINT 20/5
4. PRINT “Good” + “Morning”
C.
1. CLS
INPUT “ENTER NUMBER”, N1
INPUT “ENTER NUMBER”, N2
N3 = N1 + N2
PRINT “THE SUM IS”, N3
2. INPUT “ENTER YOUR NAME”, NAME$
INPUT “ENTER MARKS”, M1
PRINT “HELLO ”,NAME$
PRINT “YOU SCORED ”, M1
D.
1. Every programming language has three types of programming
statements. They are:
Sequential, Conditional, Iterations or Loops.
2. IF command is used for executing a statement based on a condition. It
implements the branching of the execution in two parts:
a. If the condition written next to IF is true, then the statement part
will be executed.
b. If the condition is false, then the statement after the ELSE part will
be executed.
Example: REM PROGRAM TO CHECK A NUMBER FOR EVEN AND
ODD
INPUT “ENTER NUMBER”, A
IF A MOD 2=0 THEN
PRINT “EVEN NUMBER”
ELSE
PRINT “ODD NUMBER”
END
3. Operators are the symbols used for evaluating an expression in a
language. For example,
A=B+C, where = and + are operators.
4. We use relational operators to make a comparison between any two
values. It displays the result as true or false depending upon the value
given.
For example,
A=7
B=8
Print A>B ‘this will give false as A is not greater than B. Here, > is a
relational operator.
5. The ELSEIF statement allows us to execute a set of statements if the
previous condition is false. It is generally used when we have multiple
conditions in a program.
INPUT “ENTER BILL AMOUNT”, AMT
IF AMT <= 6000 THEN
DISCOUNT = 0
ELSEIF AMT > 6000 AND AMT <= 15000 THEN
DISCOUNT = 0.2 * AMT
ELSEIF AMT > 15000 AND AMT <= 50000 THEN
DISCOUNT = 0.3 * AMT
ELSE
DISCOUNT = 0.7 * AMT
END IF