SET- 6
11. Write the output of the given program:
DECLARE SUB Result:
CALL Result
END
SUB Result
For I = 1 to 9 STEP 2
Sum=Sum +I^2
Next I
PRINT Sum
END SUB
Ans: Output
165
12. Rewrite the following program after correcting the bugs:
REM to store Name, post and salary
OPENEMP.DOCFOROUTAS#1
INPUT “Enter Name”; N
INPUT “Enter post”; P$
INPUT “Enter salary”; S
WRITE #2, N$,P$,S
CLOSE #1
END
Ans: Correct program
REM to store Name, post and salary
OPEN “EMP.DOC” FOROUTPUT AS#1
INPUT “Enter Name”; N$
INPUT “Enter post”; P$
INPUT “Enter salary”; S
WRITE #1, N$,P$,S
CLOSE #1
END
13. Study the following program and answer the following questions:
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.
Ans: The string library functions used in the above program are: LEN, UCASE$ and MID$.
b) Write down the missing statements in the main module to execute the program.
Ans: The missing statement in the main module to execute the program is: PRINT COUNT(W$)
11. Write the output of the given program:
DECLARE SUB Result:
CALL Result
END
SUB Result
For I = 1 to 9 STEP 2
Sum=Sum +I^2
Next I
PRINT Sum
END SUB
Ans: Output
165
12. Rewrite the following program after correcting the bugs:
REM to store Name, post and salary
OPENEMP.DOCFOROUTAS#1
INPUT “Enter Name”; N
INPUT “Enter post”; P$
INPUT “Enter salary”; S
WRITE #2, N$,P$,S
CLOSE #1
END
Ans: Correct program
REM to store Name, post and salary
OPEN “EMP.DOC” FOROUTPUT AS#1
INPUT “Enter Name”; N$
INPUT “Enter post”; P$
INPUT “Enter salary”; S
WRITE #1, N$,P$,S
CLOSE #1
END
13. Study the following program and answer the following questions:
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.
Ans: The string library functions used in the above program are: LEN, UCASE$ and MID$.
b) Write down the missing statements in the main module to execute the program.
Ans: The missing statement in the main module to execute the program is: PRINT COUNT(W$)
No comments:
Post a Comment