Analytical
Questions [27]
1.
[SEE
2075 S2]
DECLARE
SUB TRIM (W$)
CLS
INPUT "Enter word" ; WO$
CALL TRIM (WO$)
END
SUB TRIM (WO$)
FOR I = 1 TO LEN (W$)
PRINT LEFT$ (W$, I)
NEXT I
END SUB
i. What will be
the output if input string is "SEE" in the above program?
Output
S
SE
SEE
ii. List the
real parameter used in the above program.
Ans: Real parameter is WO$
2.
[SQE 2075K]
DECLARE
SUB SERIES(A, R, N)
CLS
CLS
INPUT "ENTER
FIRST TERM"; X
INPUT "NUMBER OF TERMS TO BE GENERATED:"; Z
CALL SERIES (X,Y,Z)
END
SUB SERIES (A, R, N)
FOR I = 1 TO N
PRINT A
A=A*R
NEXT
END SUB
INPUT "NUMBER OF TERMS TO BE GENERATED:"; Z
CALL SERIES (X,Y,Z)
END
SUB SERIES (A, R, N)
FOR I = 1 TO N
PRINT A
A=A*R
NEXT
END SUB
a. What will be the
output if the user input 3, 2 and 4 for variables X, Y and Z variables?
Ans: The output will be
3
6
12
24
3
6
12
24
b. What type of
parameter X, Y and Z are?
Ans: X,
Y and Z are actual parameters.
3.
[SLC 2069]
DECLARE SUB EXAM (N$)
INPUT
"Enter Word", WO$
CALL
EXAM (WO$)
END
SUB
EXAM(N$)
FOR
I=1 TO LEN (N$)
PRINT
RIGHT$(N$,1)
NEXT
I
END
SUB
i. Write the
names of two built in functions used in the program.
Ans:
The names of two built in functions are LEN and RIGHT$
ii. List the
real parameter and formal parameter in the program.
Ans: The real
parameter is WO$ and formal parameter is N$
4.
[SLC 2066]
DECLARE FUNCTION Num(N)
INPUT N
S=Num(N)
PRINT S
END
FUNCTION Num(N)
X=Int(17/N)
Y=15 MOD N
Num=X +Y
END FUNCTION
INPUT N
S=Num(N)
PRINT S
END
FUNCTION Num(N)
X=Int(17/N)
Y=15 MOD N
Num=X +Y
END FUNCTION
i.
Write the name of the function used in the above program.
Ans: The name of the function is
Num.
ii. List out the mathematical function (Library function) used in the above program.
ii. List out the mathematical function (Library function) used in the above program.
Ans: The library function is Int(
)
5.
[SLC 2065]
DECLARE
FUNCTION xyz(N)
FOR I = 1 TO 5
READ N
Z=xyz(N)
S=S+Z
NEXT I
PRINT S
DATA 10,13,15,4,6
END
FUNCTION xyz(N)
IF N MOD 2=0 THEN xyz=N
END FUNCTION
FOR I = 1 TO 5
READ N
Z=xyz(N)
S=S+Z
NEXT I
PRINT S
DATA 10,13,15,4,6
END
FUNCTION xyz(N)
IF N MOD 2=0 THEN xyz=N
END FUNCTION
a) What is the name of the
function used in the above program?
Ans: The
name of the function is xyz
b) How many times the function will be called in the above program?
b) How many times the function will be called in the above program?
Ans: The
function will be called 5 times.
6.
[SLC 2065 S]
DECLARE FUNCTION Diff(A,B)
CLS
INPUT “Enter first number”;A
INPUT “Enter second number”;B
PRINT “The difference of the two
number=”;Diff(A,B)
END
FUNCTION Diff(A,B)
D=A-B
Diff=D
END FUNCTION
i.
What will be the output of the program if the user enters 200 as the first
number and 100 as the second number.
Ans: The output is:
The difference of the two
number=100
ii.
Will the program run if the first line (i.e. DECLARE…..) is deleted?
Ans: Yes, the program will run if
the first line (i.e. DECLARE…) is deleted.
7. [SEE
2073]
DECLARE FUNCTION Diff (A, B)
CLS
INPUT
"Enter first number" ; A
INPUT
"Enter second number" ; B
PRINT
"The difference" ; Diff (A, B)
END
FUNCTION
Diff (A, B)
difference
= A - B
Diff
= difference
END
FUNCTION.
a)
List all the numeric variables
used in the above program.
Ans: The numeric variables are A,
B and difference.
b)
List the local variables used in the
above program.
Ans: The local variables are A, B
and difference
8. [SEE
2067 S]
DECLARE
FUNCTION Prod(A,B)
CLS
INPUT
“Enter first number:”;A
INPUT
“Enter second number:”;B
PRINT
“the product of two number=”;Prod(A,B)
END
FUNCTION
Prod(A,B)
P=A*B
Prod=P
END
FUNCTION
a) List all the numerical
variables used in the program.
The numerical variables are A, B and P
b) List all the local variables
used in the program.
The local variable is P
9. [SEE
2073 U]
DECLARE FUNCTION SUM
(A, B)
INPUT A
INPUT B
X = SUM (A, B)
PRINT X
END
FUNCTION SUM (A, B)
S = A+B
SUM = S
END FUNCTION.
a) Write the name of local variable used in the above FUNCTION
procedure.
Local Variable: S
b) Write the Mathematical operator and Relation operator used in
above program.
Mathematical Operator
: +
Relational Operator
: =
10.
[SLC 2072]
DECLARE FUNCTION
Prod (N)
INPUT
"Any Number"; N
X
= Prod (N)
PRINT
x
END
FUNCTION
Prod (N)
F=
1
FOR
K = 1 TO N
F
= F * K
NEXT
K
Prod
= F
END
FUNCTION
a)
Write the name
of the user defined function used in above program.
Ans:
The name of the user defined function used in above program is Prod.
b)
Name
the loop in above program?
Ans: The name of loop is FOR….NEXT loop.
[SLC 2069 S]
11. DECLARE
FUNCTION CHK$(N)
N=57
PRINT “The number is”; CHK$(N)
END
N=57
PRINT “The number is”; CHK$(N)
END
FUNCTION
CHK$(N)
FOR I = 1 TO N
IF N MOD I = 0 THEN C=C+1
NEXT I
IF C>2 THEN
CHK$=”Composite”
ELSE
CHK$=”Prime”
END IF
END FUNCTION
FOR I = 1 TO N
IF N MOD I = 0 THEN C=C+1
NEXT I
IF C>2 THEN
CHK$=”Composite”
ELSE
CHK$=”Prime”
END IF
END FUNCTION
i. Will the above program execute
if “DECLARE FUNCTION….” is deleted.
Ans:
Yes, the program will run if the first line (i.e. DECLARE…) is deleted.
ii. Why $ sign is used in the name of the above function.
ii. Why $ sign is used in the name of the above function.
Ans:
$ sign is used in the name of the above function because the function returns
string value.
12. [SQE
2074K]
DECLARE
SUB PATTRA (N)
N
= 7
CALL
PATTRA(N)
END
SUB
PATTRA(N)
FOR
I = 1 to 5
PRINT
N
IF
N MOD 2 = 1 THEN
N
= (N*2) + 1
ELSE
N
= N / 2
END
IF
NEXT
I
END
SUB
a)
Write the output of the above program?
Ans: The output is:
7
15
31
63
127
b)
Write down the function of MOD in the above program.
Ans: The function of MOD operator is to find
the remainder.
13. [SLC 2068]
Declare
function count(N$)
Input
“Enter a word”; R$
C=
Count(R$)
Print
C
END
END
Function
count(N$)
For k=1 to LEN(n$)
X$=MID$(N$,K,1)
IF UCASE$(X$)=”A” then
X=X+1
End if
Next K
Count = X
End function
For k=1 to LEN(n$)
X$=MID$(N$,K,1)
IF UCASE$(X$)=”A” then
X=X+1
End if
Next K
Count = X
End function
i) List any two library functions
used in the above program.
Ans:
Any two library functions are LEN( ) and MID$( ).
ii) Write the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.
ii) Write the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.
Ans:
The use of variable ‘C’ is to store the value returned by the function count.
14.
[PMT
2075]
DECLARE SUB OT (N$)
N$ = "Computer Science"
CALL OT(N$)
END
SUB OT (N$)
B = LEN(N$)
c = 1
WHILE c <= B
m$ = MID$(N$, c, 1)
PRINT m$;
c = c + 2
WEND
END SUB
a. What is the value of B in the above program?
Ans: The value of B is 16 in the above program.
b. How many parameters are used in the above sub
procedure?
Ans: Only one parameter is used in the above program.
15. [SLC 2066 S]
DECLARE FUNCTION COUNT(A$)
Input “Enter a word”; W$
END
Input “Enter a word”; W$
END
Function Count(A$)
B=LEN(A$)
C$=UCASE$(A$)
FOR I=1 TO B
E$=MID$(C$,I,1)
IF E$=”A” OR E$=”E” OR E$=”I” OR E$=”O” OR E$=”U” THEN C=C+1
END IF
NEXT I
COUNT=C
END FUNCTION
B=LEN(A$)
C$=UCASE$(A$)
FOR I=1 TO B
E$=MID$(C$,I,1)
IF E$=”A” OR E$=”E” OR E$=”I” OR E$=”O” OR E$=”U” THEN C=C+1
END IF
NEXT I
COUNT=C
END FUNCTION
i.
List the string Library functions used in the above program.
Ans: The string Library functions used in the
above program are LEN( ), UCASE$( ) and MID$( ).
ii. Write down the missing statements in the main module to execute the program.
ii. Write down the missing statements in the main module to execute the program.
Ans: The missing statements in the main module
to execute the program is PRINT COUNT(W$)
16.
[SLC 2071]
DECLARE SUB Stde(N$U)
FOR Loop = 1 TO 5
READ NM$(Loop)
NEXT Loop
DATA RAMA, PRATIMA, PRASANT
DATA NISHA, RUDHRA
CALL Stde(NM$U)
END
SUB Stde(N$U)
PRINT “Name starting from P”
FOR J = 1 TO 5
C$=MID$(N$,(J),1,1)
IF C$=”P” THEN
PRINT N$(J)
END IF
NEXT J
END SUB
i.
List the library function used in the above program.
Ans: The library function used in
the above program is MID$( ).
ii.
List the conditional statement used in the above program.
Ans: The conditional statement
used in the above program is IF….THEN (i.e. IF C$ = “P” THEN).
17.
[SLC 2068 S]
DECLARE
SUB ABC(X,Y,Z)
FOR P=1 TO 3
READ A,B,C
CALL ABC(A,B,C)
NEXT P
DATA 5,4,3,2,1,6,7,8,4
END
SUB ABC(X,Y,Z)
T=X+Y+Z
IF T MOD 2 = 0 THEN
PRINT T
END IF
END SUB
i.
List any two variables used in the above program.
Ans: Any two variables used in
the above program are X and Y
ii.
How many times SUB-procedure will be called when program is executed?
Ans: The SUB procedure will be
called 3 times.
18.
[SLC 2071 S]
DECLARE FUNCTION JPT (N)
FOR
ctr = 1 TO 6
READ
N
J
= JPT (N)
Sum
= Sum + J
NEXT
ctr
PRINT
Sum
DATA
10, 20, 30, 40, 50, 60
END
FUNCTION
JPT (N)
IF
N MOD 2 = 0 THEN JPT = N
END
FUNCTION
a) What
is name to the function used in the above program?
Ans: The name of the
function used in the above program is JPT
b) How
many times the function will be executed in the above program?
Ans: The function will be executed six times.
19.
DECLARE
FUNCTION B(N)
LET N = 12345
PRINT "Sum of Digits
:"; B(N)
END
FUNCTION B(N)
WHILE N <> 0
R = N MOD 10
C = C+R
N = INT(N/10)
WEND
B = C
END FNCITON
i.
Write the variables used in the program with their type.
Ans: Numeric variables = N, R and
C
ii.
List out the different types of operators with their type used in the program.
Ans: Arithmetic Operator = MOD, +
and / :
Relational Operator = <
> and =
20.
[SEE
2074 U]
DECLARE FUNCTION
TEST (X)
X = 100
Z = TEST (X)
PRINT Z
END
FUNCTION TEST (X)
FOR I = 1 TO X
S = S +I
NEXT I
TEST = S
END FUNCTION.
a) How
many parameters are used in the above program?
1
parameter is used in above program.
b) How
many times does the statement S=S+I get executed in the above program.
The
statement S=S+I gets executed 100 times.
21.
[SLC 2067]
DECLARE
SUB SUM(N)
INPUT”ANY NUMBER”;N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R
N=N\10
WEND
PRINT “SUM”;S
END SUB
INPUT”ANY NUMBER”;N
CALL SUM(N)
END
SUB SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R
N=N\10
WEND
PRINT “SUM”;S
END SUB
a) In which condition the statements within the
WHILE….WEND looping statement will not be executed?
Ans: When the condition is false (i.e. Value of N=0) ,
the statements within the WHILE….WEND looping statement will not be executed
b)
Will
the output be the same if we place “/” instead of”\” in the above program.
Ans: No. the output will not same if we place “/”
instead of”\” in the above program.
22.
[SLC 2064]
DECLARE FUNCTION
CELLS$(W$)
W$=”CYBER”
PRINT CELL$(W$)
END
FUNCTION CELL$
K=LEN(W$)
FOR I = K TO 1 STEP
-2
M$=M$+MID$(W$,I,1)
NEXT I
CELLS$=M$
END FUNCTION
a) Why
is $(dollar) sign followed in the function name?
Ans: $(dollar) sign followed in
the function name because the function returns string value.
b) What
will be the output of the program when it is executed?
Ans: The output is : CBR
c) What
will be the output of the program when FOR loop is changed as FOR I= 1 TO K
STEP 2?
Ans: The output is: RBC
d) What
is the name of sign “+” used in the program and what operation does it perform?
Ans: The name of sign “+” is
string operator and it is used to join the string i.e. string concatenation.
23.
[SLC 2070]
DECLARE
FUNCTION Sum(A,B)
INPUT
“Enter first number:”; A
INPUT
“Enter second number:”; B
PRINT “The sum of the two
number=”;Sum(A,B)
END
FUNCTION
SUM(A,B)
S=A+B
Sum=S
END
FUNCTION
a) List the
numerical variables used in the above program.
Ans: The numerical variables used
in the above program are S, A and B.
b) Will the program
run if the first line (i.e. DECLARE….) is deleted?
Ans: Yes, the program will run if
the first line (i.e. DECLARE….) is deleted
24.
[SLC 2070 S]
DECLARE
FUNCTION rev$ (N$)
INPUT "Any string"; N$
PRINT rev$ (N$)
END
FUNCTION
rev$ (N$)
FOR X = LEN (N$) to 1 STEP -1
A$=MID$ (N$, X, 1)
B$ = B$ + A$
NEXT X
rev$ = B$
END
FUNCTION
a.
List the library
function used in the above program.
Ans:
The library function used in the above program are LEN( ) and MID$( )
b.
What will be the
maximum value of X if the N$ is equal to "Computer".
Ans:
be the maximum value of X if the N$ is equal to "Computer" is 8.
25.
[SEE 2074]
DECLARE FUNCTION SUM (N)
INPUT "Enter any
number", N
S = SUM (N)
PRINT "The Sum of individual
digit is:", S
END
FUNCTION SUM (N)
WHILE N > 0
R = N MOD 10
T = T + R
N = N\10
WEND
SUM = T
END FUNCTION.
State
the purpose of using variable S in line 4 in above program.
Ans: The purpose of using
variable S in line 4 in above program is to store the value returned by the
function SUM.
Write the use of MOD in above
program.
Ans:
The use of MOD operator is to return the remainder.
26.
[SEE 2075 U]
DECLARE SUB TEST (N$ )
INPUT N$
CALL TEST ( N$ )
END
SUB TEST (N$ )
FOR P = 1 TO LEN ( N$ )
B$ = MID$ (N$, P, 1)
IF LCASE$ (B$) = “a” THEN
C = C + 1
END IF
NEXT P
PRINT C
END SUB
a) Write
the name of the sub procedure used in the above program.
Ans: The name of the sub procedure used in the
above program is TEST
b) Write
any two library functions used in the above program.
Ans: Any two library functions used in the
above program are MID$( ) and LEN( )
27. [MM
2076]
DECLARE FUNCTION SUM
(N)
FOR I = 1TO 4
READ N
DATA 15 ,25, 69
PRINT SUM (N)
NEXT
END
FUNCTION SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R
N=INT (N\10)
WEND
SUM=S
END FUNCTION
a) How
many times the main function will be executed in the above program?
Ans: The main function will be executed 4
times.
b) List
the relational operators used in the above proram?
Ans: The relational operators used are : = and
< >