SET 5
11. Rewrite the following program after correcting the bugs:
DECLARE SUB Series()
CLS
EXECUTE Series
END
SUB Series()
REM program to generate 1 1 2 3 5…. Up to 20th terms
A=1
B=1
FOR ctr= 10 TO 1
DISPLAY A;B;
A=A+B
B=A+B
EXT ctr
END Series()
Ans: Correct program
DECLARE SUB Series()
CLS
CALL Series
END
SUB Series()
REM program to generate 1 1 2 3 5…. Up to 20th terms
A=1
B=1
FOR ctr= 1 TO 10
PRINT A;B;
A=A+B
B=A+B
NEXT ctr
END SUB
12. Write the output of the following program:
DECLARE FUNCTION AREA(L,B)
CLS
LET L =100
LET B = 20
LET ans=AREA(L,B)
PRINT “The area=”,ans
END
FUNCTION AREA(L,B)
ar=L*B
AREA=ar
END FUNCTION
Ans: Output
The area=2000
13. Analyse the program given below and answer the questions.
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.
Ans: The numerical variables used in the program are A, B and P.
b) List all the local variables used in the program.
Ans: The local variable used in the program is P.
11. Rewrite the following program after correcting the bugs:
DECLARE SUB Series()
CLS
EXECUTE Series
END
SUB Series()
REM program to generate 1 1 2 3 5…. Up to 20th terms
A=1
B=1
FOR ctr= 10 TO 1
DISPLAY A;B;
A=A+B
B=A+B
EXT ctr
END Series()
Ans: Correct program
DECLARE SUB Series()
CLS
CALL Series
END
SUB Series()
REM program to generate 1 1 2 3 5…. Up to 20th terms
A=1
B=1
FOR ctr= 1 TO 10
PRINT A;B;
A=A+B
B=A+B
NEXT ctr
END SUB
12. Write the output of the following program:
DECLARE FUNCTION AREA(L,B)
CLS
LET L =100
LET B = 20
LET ans=AREA(L,B)
PRINT “The area=”,ans
END
FUNCTION AREA(L,B)
ar=L*B
AREA=ar
END FUNCTION
Ans: Output
The area=2000
13. Analyse the program given below and answer the questions.
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.
Ans: The numerical variables used in the program are A, B and P.
b) List all the local variables used in the program.
Ans: The local variable used in the program is P.
No comments:
Post a Comment