Set 1
11. Write the output of the given programs:
DECLARE SUB RESULT ()
CALL RESULT
END
SUB RESULT
N=5
C=1
WHILE C<=5
PRINT N
N=N*10+5
C=C+1
WEND
END SUB
Ans: Output
5
55
555
5555
55555
12. Re-write the given program after correcting the bugs:
REM to store name and age in a sequential data file STD.DOC
OPEN STD.DOC FOR OUT AS#1
INPUT “Enter name”;N
INPUT “Enter age”;A
WRITE 1,N$,A
CLOSE #1
END
Ans: Correct program
REM to store name and age in a sequential data file STD.DOC
OPEN “STD.DOC” FOR OUTPUT AS#1
INPUT “Enter name”;N$
INPUT “Enter age”;A
WRITE #1,N$,A
CLOSE #1
END
13. Study the following program and answer the given questions:
DECLARE FUNCTION A(X)
X=5
Z=A(X)
PRINT Z
END
FUNCTION A(X)
FOR I = 1 TO X
S=S+I
NEXT I
A=S
END FUNCTION
a) How many parameters are used in the program?
Ans: There is one parameter used in the program.
b) How many times does the statement S=S+I execute in the above program?
Ans: The statement S=S+I execute 5 times in the above program.
11. Write the output of the given programs:
DECLARE SUB RESULT ()
CALL RESULT
END
SUB RESULT
N=5
C=1
WHILE C<=5
PRINT N
N=N*10+5
C=C+1
WEND
END SUB
Ans: Output
5
55
555
5555
55555
12. Re-write the given program after correcting the bugs:
REM to store name and age in a sequential data file STD.DOC
OPEN STD.DOC FOR OUT AS#1
INPUT “Enter name”;N
INPUT “Enter age”;A
WRITE 1,N$,A
CLOSE #1
END
Ans: Correct program
REM to store name and age in a sequential data file STD.DOC
OPEN “STD.DOC” FOR OUTPUT AS#1
INPUT “Enter name”;N$
INPUT “Enter age”;A
WRITE #1,N$,A
CLOSE #1
END
13. Study the following program and answer the given questions:
DECLARE FUNCTION A(X)
X=5
Z=A(X)
PRINT Z
END
FUNCTION A(X)
FOR I = 1 TO X
S=S+I
NEXT I
A=S
END FUNCTION
a) How many parameters are used in the program?
Ans: There is one parameter used in the program.
b) How many times does the statement S=S+I execute in the above program?
Ans: The statement S=S+I execute 5 times in the above program.
No comments:
Post a Comment