1.
DECLARE
SUB TEST(A, B, C)
LET X=4
LET Y=7
LET Z=12
CALL TEST (X, Y, Z)
PRINT X, Y, Z
END
SUB TEST(A, B, C)
A=A+3
B=B+2
SUM=A+B+C/3
PRINT SUM
END SUB
i)What happens if CALL
TEST(X, Y, Z) is replaced by CALL TEST(A, B, C)
ii)List the formal and
real parameters used in the above program.
2.
DECLARE
SUB word(B$)
CLS
A$ = “Computer
science”
B$ = “Computer
Programming”
Call word(a$)
Print A$
Call word (B$)
End
SUB WORD (c$)
L = LEN(C$)
POS = (80 – L)/2
Print tab (pos); C$
C$ = “examination”
END SUB
i)Write the output of the above
program.
ii)How is the arguments passed?
iii)What will the print A$
statement in module print?
iv)Is C$ actual or formal
parameter?
3.
DECLARE
SUB question (a, b, c)
CLS
x=10 : y=20 : z=15
CALL
question (x, y, z)
END
SUB
question (a, b, c)
a=a+10
b= b +
a
c=a +b
PRINT
a, b, c
END SUB
i.Write
actual and formal parameter used in the program.
ii.What
would be its output if x=1, y=2,z=3?
4.
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
i.List the formal parameters and
actual parameters used in the above program.
ii.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?
5.
DECLARE
SUB ADD(A,B)
CLS
INPUT
“ENTER TWO NUMBERS”; X,Y
CALL
ADD(X,Y)
END
SUB
ADD(A,B)
C
= A + B
PRINT
“Sum is”; C
END
SUB
i.Write
the name of procedure in above program.
ii.List
arguments and parameters in the above program.
6. DECLARE SUB TEST (A, B, C)
LET X = 4
LET Y = 7
LET Z = 12
CALL TEST (X, Y, Z)
PRINT X, Y, Z
END
SUB TEST (A, B, C)
A=A+3
B=B+2
SUM=A+B+C/3
PRINT SUM
END SUB
i.What will be the output of the
above program?
ii.List the arguments and
parameters used in the above program.
7.
DECLARE
SUB TEST (A, B, C)
INPUT "Enter three different
numbers:"; X, Y, Z
CALL TEST(X, Y, Z)
END
SUB TEST (A, B, C)
IF A > B AND A > C THEN
T = A + B + C
ELSEIF B > A AND B > C THEN
T = A * B * C
ELSE
T = (B + A) / C
END IF
PRINT T
END SUB
i.List formal and
real parameters used in the above program.
ii.What happens if
“CALL TEST(X,Y,Z)” is replace by “CALL TEST(A,B,C)”.
8.
DECLARE
FUNCTION ADD(N)
CLS
FOR CNT= 1 TO 3
READ NUM
PRINT ADD (NUM)
NEXT CNT
DATA 8, 7, 3
END
FUNCTION ADD(N)
S=0
FOR G=1 TO N
S=S+G
NEXT G
ADD=S
END FUNCTION
i.Name the actual and formal
parameter used in above program.
ii.What is the value of NUM when
the value of CNT is 2?
9.
DECLARE SUB RESULT (N)
CLS
INPUT
"ENTER ANY NUMBER"; NUM
CALL
RESULT (NUM)
END
SUB
RESULT (N)
DO
UNTIL N = 0
R
= N MOD 10
IF
R MOD 2 = 0 THEN
S
= S + R
END
IF
N
= N \ 10
LOOP
PRINT
S
END
SUB
i.List the actual and formal
parameters in the above program.
ii. What will be the output of
the program if the input is 1234?
10.
DECLARE
SUB TEST (W$)
CLS
INPUT
”ENTER AWORD”; A$
CALL
TEST (A$)
END
SUB
TEST (W$)
FOR
K=1 TO LEN (W$)
U$=MID$(W$,K,1)+U$
NEXT
K
PRINT
U$
END SUB
i.List the argument
and parameters used in the above program.
List the library
function used in the above program.
11.
DECLARE SUB EXAM (N$)
CLS
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.
ii.List
the real name and formal parameter in the program.
12.
DECLARE
SUB RESULT (TXT$)
TEXT$ = "SYSTEM
PROGRAMMING"
CALL RESULT (TEXT$)
END
SUB RESULT (TXT$)
FOR I = 1 TO LEN(TXT$)
SCAN$ = UCASE$(MID$(TXT$, I, 1))
IF I MOD 2 = 0 THEN
TEMP$ = TEMP$ + UCASE$(SCAN$)
ELSE
TEMP$ = TEMP$ + LCASE$(SCAN$)
END IF
NEXT I
PRINT TEMP$
END SUB
i.What is the output of the above
program?
ii.List the actual and the formal
parameters sued in the program.
13.
DECALRE
SUB ADD(A,B)
CLS
X= 4
Y= 3
CALL ADD(X,Y)
END
SUB ADD(A,B)
Z = A +B
PRINT A;”+”;B;’”=”;Z
END SUB
i.List the local and global
variables.
ii.What is the name of procedure used in above
program?
14.
DECLARE
FUNCTION XYZ(N)
CLS
A = 135 : B = A
A = XYZ(A)
PRINT “THE RESULT IS”,
IF X = B THEN PRINT “OK” ELSE
PRINT “NO”
END
FUNCTION XYZ(N)
DO WHILE N > 0
RE = N MOD 10
N = N / 10
T = N * 10 + RE
LOOP
XYZ = T
END FUNCTION
a)
What
will be the output of the above program?
b)
Count
the total number of global and local variables in the above program and list
them.
c)
Can
we replace the fourth line of the program X = XYZ(A) by X = XYZ(131) or not?
Differentiate between X = XYZ(A) and XYZ(131)
d)
If
the value of variable N = 7 the what will be the value of variable RE?
15.
DECLARE
FUNCTION PRO (A,B)
CLS
INPUT
“Enter two number “:A,B
RES=
PRO (A,B)
PRINT
“PRODUCT =”: RES
END
FUNCTION
PRO (A,B)
P=A*B
PRO = P
END
FUNCTION
i)
Write the local variables and global variables used in the program.
ii)
Writ the name of the function used in the program.
16.
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
i.List all the numerical
variables used in the program.
ii.List all the local variables
used in the program.
17.
DECLARE
FUNCTION DESP$(A$,B$,C$)
INPUT A$,B$,C$
PRINT DISP$( A$,B$,C$)
END
FUNCTION DESP$(A$, B$, C$)
L1=LEN(A$)
L2=LEN(B$)
L3=LEN(C$)
IF L1>L2 AND L1>L3 THEN
ANS$=A$
ELSEIF L2>L3 AND L2>L1 THEN
ANS$=B$
ELSE
ANS$=C$
END IF
DISP$=ANS$
END FUNCTION
i.Make a list of local variables
in the given program.
ii.What is the function of PRINT
DISP$(A$,B$,C$)?
18.
DECLARE
FUNCTION COUNT (N ())
DIM N(10)
FOR I = 1 TO 10
READ N(I)
NEXT
DATA
12,34,56,11,13,45,33,90,99,78,87
A= COUNT (N ())
END
FUNCTION COUNT (N ())
FOR J = 1 TO 10
IF N (I) MOD 2= 0 THEN
E=E+1
ELSE
O=O+1
NEXTPRINT O, E
END FUNCTION
i.What may be the output of the
above program?
ii.List out global and local
variables used in the program.
iii.List out expression used in
the program.
iv. How the argument is passed
either by reference or by value?
19.
DECLARE
FUNCTION NUM(N)
CLS
N=14
PRINT
NUM(N)
END
FUNCTION
NUM(N)
WHILE
N<>0
R=N MOD
2
S=S+R*10^P
P=P+1
N=N\2
WEND
NUM=S
END
FUNCTION
i.List
the local variable used in the function procedure.
ii.What
will be the output if the program?
20.
DECLARE
SUB TEST(A,B)
CLS
X=2: Y=2
CALL TEXT(X,Y)
PRINT X,Y
CLS
X=2: Y=2
CALL TEXT(X,Y)
PRINT X,Y
END
SUB TEST(P,Q)
FOR I= P TO Q
P=P+Q
Q=P+Q
NEXT
PRINT P,Q
END SUB
i.What will be the output of the above program?
ii.List down the global variable used in the above program.
21.
DECLARE
SUB CONVERT(N)
CLS
INPUT
“ENTER A NUMBER”; N
CALL
CONVERT(N)
END
SUB
CONVERT(N)
A=2
WHILE
A<>0
R
= N MOD A
A
= A \ B
B$
= STR$(R) +B$
WEND
PRINT
R
END
SUB
i.List
out the number of local variable used in SUB procedure.
ii.What
will be the output of above program if N=12
22.
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
i.What
will the output if X=10, Y=8 and Z=5.
ii.List
out the local variables and global variable in the above program.
23.
DECLARE SUB SERIES(X, Y, Z)
DECLARE
FUNCTION SUM(X, Y)
DIM
SHARED I
CLS
INPUT
“Enter First Term”;X
INPUT
“Common Difference”;Y
INPUT
“Enter Number of Terms to be generated”; Z
CALL
SERIES(X, Y, Z)
END
SUB
SERIES (X, Y, Z)
FOR I =
1 TO Z
PRINT X
X =
SUM(X, Y)
NEXT I
END SUB
FUNCTION
SUM (X, Y)
SUM=X+Y
END
FUNCTION
a)
What
will be the output of the program if the user inputs 2, 3, 4 for the variables
X, Y, Z respectively?
b)
How
many times the function SUM(X, Y) will be executed if the values of X, Y, Z are
2, 4, 6 respectively?
c)
What
type of variables X, Y and I are?
d)
Will
the program run if the value of Z is less than X and Y?
24.
DECLARE
SUB CHECK()
CLS
CALL
CHECK()
END
SUB
CHECK
A=1
FOR I=
1 TO 5
PRINT A
A=A+3
NEXT I
END SUB
i.Write the name of the procedure
used in the above program.
ii.What will happen if CALL
statement is missing.
25.
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.
ii.List out the mathematical function (Library function) used in the above program.
Sir please upload answer also
ReplyDeletehttps://seeqbasicomputer.blogspot.com/2018/09/qbasic-program-analytical-programs.html?m=1
Delete