Analytical Questions
1.
NPABSON PRE BOARD
DECLARE FUNCTION test$ (A$)
CLS
INPUT “ENTER ANY WORD”; T$
PRINT test$(t$)
END
FUNCTION test$ (A$)
FOR M = LEN(A$) TO 1 STEP
-1
C$= C$+ MID$(A$, M,1)
NEXT M
Test$ = C$
END FUNCTION
a) List the formal and actual parameters used in
the program given above.
b) List the library function used in the above
program.
2. [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
a) What
will be the output if input string is "SEE" in the above program?
b) List
the real parameter used in the above program.
3.
[SQE 2075K]
DECLARE SUB SERIES(A,
R, N)
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
a)
What will be the output if the user input 3, 2
and 4 for variables X, Y and Z variables?
b) What type
of parameter X, Y and Z are?
4.
[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
a) Write
the names of two built in functions used in the program.
b) List
the real parameter and formal parameter in the program.
5. SET
DECLARE SUB SEQUENCE (A,B,C)
CLS
X=10
Y=20
Z=30
CALL SEQUENCE (X,Y,Z)
END
SUB SEQUENCE (C,B,A)
PRINT A,B,C
END SUB
a) List the formal parameters and actual parameters
used in the above program.
b) Will the above program execute if the position of
parameter is to be changed? If ‘yes’ then which sequence of number list will it
print either 10,20,30 or 30,20,10?
6.
MAAF MT 2079
DECLARE
FUNCTION count(bs)
INPUT
a$
num=count
(a$)
PRINT
num
END
FUNCTION
count (b$)
FOR
K=1 to LEN (bs)
aS=MIDS(b$,
K, 1)
IF
UCASES(a$)="D" THEN
c=c+1
END
IF
NEXT
K
count
= c
END
FUNCTION
a) What is the name of FUNCTION procedure used
in above program?
b) List out the formal and actual arguments
from the above program.
7.
[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
a) What is
the name of the function used in the above program?
b) How
many times the function will be called in the above program?
8. SEE 2078
DECLARE FUNCTION TEST(X)
X=100
Z=TEST(X)
PRINT Z
END
FUNCTION TEST(X)
FOR R=1 TO X
S=S+I
NEXT R
TEST=S
END FUNCTION
a) How many parameters are used in the above
program?
b) How many times does the statement S=S+I
execute in the above program?
9. [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
a) List
any two variables used in the above program.
b) How
many times SUB-procedure will be called when program is executed?
10. [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?
b) How
many times does the statement S=S+I get executed in the above program.
11. [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?
b)
List the relational
operators used in the above program?
12. SEE Grade Promotion 2078
- 1
DECLARE
FUNCTION SUM(N)
CLS
INPUT”Enter
any number”: N
X=SUM(N)
PRINT”The
sum of individual digit is “; X
END
FUNCTION
SUM(N)
WHILE
N<>0
R=N
MOD 10
S=S+R
N=INT(N/10)
WEND
SUM=S
END
FUNCTION
a) Write
the function of INT.
b) How
many times the WHILE…..WEND LOOP repeats if the value of N is 123?
13.
[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?
b)
How many times the
function will be executed in the above program?
14. SET
DECLARE FUNCTION greater(A,B)
CLS
INPUT”Enter first number”; X
INPUT”Enter second number”; Y
C = greater(X, Y)
PRINT "The greater number
is " ; C
END
FUNCTION greater(A,B)
IF A>B THEN
GR = A
ELSE
GR = B
END IF
Greater = GR
END FUNCTION
a)
What will be the output of the program if X = 6 and Y =
7?
b)
How many arguments are used in above program?
15. PABSON FIRST
TERM 2079
DECLARE FUNCTION FACT( N )
CLS
INPUT “Enter no”; N
PRINT “Factorial is”; FACT
(N)
END
FUNCTION FACT (N)
F = 1
FOR X = 1 TO N
F = F * X
Next X
FACT = F
END FUNCTION
Questions:
a) What is the name of function procedure used
in the above program?
b) What is the main objective of the above
program?
16.
[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?
b)
How many parameters are used in the above sub
procedure?
17. SEE Grade Promotion
2078 - 2
DECLARE FUNCTION Prod(A,B)
CLS
INPUT “Enter first number”; A
INPUT “Enter second number”; B
PRINT “The product of the 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.
b) List the local variable/s used in the above
program.
18.
PABSON PRE BOARD-1
DECLARE SUB PC$ (N)
CLS
INPUT "Enter a number"; N
CALL PC$ (N)
END
SUB PC$ (N)
FOR I=2 TO N-1
R=N MOD I
IF C=0 THEN
PRINT "Prime number"
ELSE
PRINT "Composite number"
ENDIF
END SUB
a)
What
is the name of sub procedure?
b)
List
the local variable.
19. [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.
b) List
the local variables used in the above program.
20. [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.
b) List
all the local variables used in the program.
21. [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.
b)
Write the Mathematical
operator and Relation operator used in above program.
22. SET
DECLARE SUB SERIES(A, B)
DECLARE FUNCTION SUM(P,Q)
COMMON SHARED N
INPUT “Enter First Term”;X
INPUT “Enter Second Term”;Y
INPUT “Enter Number of Terms to be generated”; N
CALL SERIES(X, Y)
END
SUB SERIES (A, B)
FOR I = 1 TO N
PRINT A
A=SUM(A,B)
NEXT I
END SUB
FUNCTION SUM (P,Q)
SUM=P+Q
END FUNCTION
a)
What
will the output if X=10, Y=8 and N=5.
b)
List
out the local variables and global variable in the above program.
23.
PABSON 2070
DECLARE SUB TEST()
DIM SHARED A$,B$,C$
CLS
FOR P= 1 TO 3
READ A$,B$,C$
NEXT P
DATA “BAGMATI” , “SAGARMATHA” ,
“KOSHI”
CALL TEST
END
SUB TEST
L$=A$
IF LEN(B$)>LEN(L$) THEN L$=B$
IF LEN(C$)>LEN(L$) THEN L$=C$
PRINT L$
END SUB
a)
List
the global variables used in the above program.
b)
What
is the output of the above program?
24.
[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
a) Write the name of the function used in the above
program.
b) List out the mathematical function (Library
function) used in the above program.
25. [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.
b)
Write any two library
functions used in the above program.
26.
[SLC 2068]
Declare
function count(N$)
Input
“Enter a word”; R$
C=
Count(R$)
Print C
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
a) List
any two library functions used in the above program.
b) Write
the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.
27.
[SLC 2066 S]
DECLARE FUNCTION COUNT(A$)
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
a) List the string Library functions used in the above
program.
b) Write down the missing statements in the main module
to execute the program.
28.
[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
a) List
the library function used in the above program.
b) List
the conditional statement used in the above program.
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.
b) What will be the maximum value of X if the N$ is equal to
"Computer".
30.
SET
DECLARE SUB WORD(X$)
x$ = "COMPUTER"
END
SUB WORD (N$)
L = LEN(x$)
FOR I=L To1 STEP-2
PRINT MID$(X$,I,1)
NEXT I
END SUB
a)
What statement should be added in the main module to
execute the program?
b)
List numeric and string variable.
31. NPABSON 2078
DECLARE SUB result(m$)
m$=”NPABSAN”
END
SUB result(m$)
C=LEN(m$)
B=1
WHILE B<=C
PRINT MID$(m$, b, 1);
B=B+2
WEND
END SUB
a) What is missing in above program?
b) List out the numeric and string variable in the above
program.
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.
33. SET
DECLARE
SUB WORD(N$)
N$=”NEPAL”
CALL
WORD(N$)
END
SUB
WORD(N$)
LET
B=LEN(N$)
LET
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?
b) List out the numeric and string
variable used in the above program.
34.
SEDIPS 2070
DECLARE SUB ABC(A,B,C)
INPUT P, Q, R
CALL ABC(P,Q,R)
END
SUB ABC(A,B,C)
IF (A>B AND A<B) OR (A<B
AND A>C) THEN
PRINT “The middle number is”;A
ELSEIF (B>A AND B<C) OR
(B<A AND B>C) THEN
PRINT “The middle number is”;B
ELSE
PRINT “The middle number is”;C
END IF
END SUB
a) What is the alternative way of
invoking the SUB module.
b) Make a list of operators and
state their types.
35.
[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
a) What
will be the output of the program if the user enters 200 as the first number
and 100 as the second number.
b) Will
the program run if the first line (i.e. DECLARE…..) is deleted?
36.
NPABSON 2070
DECLARE FUNCTION BB(N)
FOR I = 1 TO 4
READ P
Y=Y+BB(P)
NEXT I
DATA 23, 45, 60, 12
PRINT Y
END
FUNCTION BB(N)
IF N MOD 2 = 0 THEN FIND=N
END FUNCTION
a)
How
many times function …….. end function execute in above program?
b)
Does
the program execute, if underlined statement is removed from the main module?
37.
[SLC 2069 S] [JEC 2078]
DECLARE FUNCTION
CHK$(N)
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
a) Will
the above program execute if “DECLARE FUNCTION….” is deleted.
b) Why $
sign is used in the name of the above function.
38. [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?
b) Write down the function of MOD in the
above program.
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.
a)
State the purpose of using variable S in line 4 in
above program.
b) Write
the use of MOD in above program.
40.
[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.
b) Name
the loop in above program?
41. [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
a) In which condition 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.
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?
b) What
will be the output of the program when it is executed?
c) What
will be the output of the program when FOR loop is changed as FOR I= 1 TO K
STEP 2?
d) What is
the name of sign “+” used in the program and what operation does it perform?
43. SOS 2078
DECLARE SUB test(c, d)
DIM SHARED c
CLS
a=90
b=100
c=95
CALL test(a, (b))
x=x+2
PRINT a,b,c,x
END
SUB test(e,f)
SHARED x
x=12
e=e+12
f=b+3
c=c+5
PRINT x;
END SUB
a) What will be the output of the program?
b) What will be the output if the statement “SHARED X” is removed
from the program?
44.
SEE MODEL SET 1
OPEN “Detail.dat” FOR INPUT
AS #1
OPEN “Temp.dat” FOR OUTPUT
AS #2
INPUT “Enter name of the
students”; S$
FOR I=1 TO 10
INPUT #1, Nm$, Cl, A
IF S$< >Nm$ THEN
WRITE #2, Nm$, Cl, A
END IF
NEXT I
CLOSE #1, #2
KILL “Detail.dat”
NAME “Temp.dat” AS
“Detail.dat”
END
a) What is the main objective of the program
given above?
b) Do you get any problem in the above program
if “Kill” statement is removed? Give reason.
45. SEDIPS 2078
OPEN “BUSRIDER.TXT” FOR INPUT AS #1
OPEN “TEMP.TXT” FOR OUTPUT AS #2
CLS
WHILE NOT EOF(1)
INPUT #1, STUDENTNAME$, CLASS, BUSCOED, BUSSTOP$
IF UCASE$(BUSSTOP$) < > UCASE$(“KATHMANDU”) THEN
WRITE#2, STUDENTNAME$, CLASS, BUSCODE, BUSSTOP$
PRINT STUDENTNAME$, CLASS, BUSCODE, BUSSTOP$
WEND
CLOSE #1, #2
KILL “BUSRIDER.TXT”
NAME “TEMP.TXT” AS “BUSRIDER.TXT”
END
a) What is the main objective of the program given above?
b) Do you get any problem ion above program if “Kill”
statement is removed? Give reason.
46. PABSON 2078 SET C
OPEN “Exam.dat” FOR INPUT AS #1
OPEN “Sample.dat” FOR OUTPUT AS #2
WHILE NOT EOF(1)
INPUT #1, Nm$, Cl, A
IF Cl < > 10 THEN
WRITE #2, Nm$, Cl, A
END IF
WEND
CLOSE #1, #2
KILL “Exam.dat”
NAME “Sample.dat” AS “Exam.dat”
END
a) What is the main objective of the program given above?
b) What is the function of EOF( ) statement in the above
program?
47. SET
Open “Record.dat” for Input
AS#1
WHILE NOT EOF (1)
INPUT #1, N$ , AD$ , PH#
PRINT N$ AD$ , PH#
WEND
CLOSE #1
END
a)
What is the purpose of EOF(1) in the above program?
b)
What happened if we are not using Open Statement in the
above program?
48.
SEE MODEL SET 2
OPEN “EMP.DAT” FOR INPUT AS
#1
DO
INPUT #1, N$, A$, S
IF UCASE$(A$)=”KATHMANDU”
THEN
PRINT N$, A$, S
END IF
LOOP WHILE NOT EOF(1)
CLOSE #1
END
a) Write the use of statement “INPUT #1, N$, A$,
S” in the above program.
b) What happens if you remove “UCASE$” from the
above program?
49.
PABSON PRE BOARD-2
CLS
OPEN "INFO.DAT"
FOR INPUT AS #5
TOP:
INPUT "ENTER
NAME"; N$
INPUT "ENTER
ADDRESS";A$
INPUT "ENTER PHONE
NUMBER";P
WRITE #5, N$, A$, P
INPUT "DO YOU WANT TO
CONTINUE (Y/N)?"; AN$
IF UCASE$ (AN$) =
"Y" THEN GOTO TOP
CLOSE #5
END
Questions:
a) List the variables used in above program.
b) What is the name of data file used in above
program?
50. SOS 2070
OPEN “DETAIL.DAT” FOR INPUT AS #1
OPEN “TEMP.DAT” FOR OUTPUT AS #2
INPUT “Name of the students”;S$
FOR I = 1 TO 10
INPUT #1,N$, C, A
IF S$<>N$ THEN
WRITE #2, N$, C, A
END IF
NEXT I
CLOSE #1,#2
KILL “DETAIL.DAT”
NAME “TEMP.DAT” AS “DETAIL.DAT”
END
a)
Will
the program run if the KILL “DETAIL.DAT” is removed? Why?
b)
If
the datafile “DETAIL.DAT” contains only 8 records, then the program will run?
Why?