1. Study the following program and answer the given questions:
CLS
INPUT A, B
SUM=A+B
PRINT "Sum of two numbers is " ; SUM
END
- List all the numerical variables used in above program. Answer:A , B, SUM
- Write the mathematical operator and relational operator used in above program. Answer:
- Write the operator name with its type. Answer:
- Does the program run if CLS is removed Answer: Yes, the program runs.
Relational operator : Equal to (=)
Arithmetic Operator: Addition(+)
Relational operator : Equal to (=)
Arithmetic Operator: Addition(+)
2. Study the following program and answer the given questions:
CLS
INPUT "Enter a number"; N
F=1
FOR I = N TO 1 STEP -1
F = F * I
NEXT I
PRINT "Factorial of " ; N; " = "; F
END
- Write down the use of line F=1. Answer: F is used as an integer constant which value is 1.
- Name the loop used in above program. Answer: FOR- NEXT LOOP
- Write the mathematical operator and relational operator used in above program. Answer:
Relational operator : Equal to (=)
Arithmetic Operator: Multiplication (*)
3. Study the following program and answer the given questions:
CLS
INPUT N
R = N MOD 2
IF R = 0 THEN
PRINT "EVEN NUMBER"
ELSE
PRINT "ODD NUMBER"
END IF
END
- List all the numeric variables used in above program. Answer: N, R
- What will be the value of R, if N=10? Answer: Value of R will be zero.
- What is the function of MOD ? Answer: MOD is used to find the remainder.
- What is the meaning of R= N MOD 2 in above program? Answer: R= N MOD 2 means the remainder will be stored in R varaible when given number(N) is divided by 2.
4. Study the following program and answer the given questions:
CLS
W$= "PURUSHOTTAM"
FOR I = 1 TO LEN(W$) STEP +2
PRINT MID$(W$,I,1)
NEXT I
END
- Write the names of two built in or Library functions used in above program. Answer: LEN, MID$
- Name the loop used in above program. Answer: FOR – NEXT LOOP
- What will be the maximum value of I if the w$ is equal to "Computer". Answer: Eight
- What will be the output of above program. Answer:
P
R
S
O
T
M
P | U | R | U | S | H | O | T | T | A | M |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
---|
5. Study the following program and answer the given questions:
CLS
X=10
FOR P = 1 TO X
PRINT P
NEXT P
END
PRINT "PLK computer SIR"
- How many times does the loop execute in above program. Answer: Ten times
- Will "PLK computer SIR" appear in output screen? Answer: No, it won’t appear.