11. Re-write the given program correcting the bugs:
DECLARE SUB Series()
CLS
EXECUTE Series
END
SUB Series
A=2
B=2
FOR ctr= 1 to 5
DISPLAY A;B;
A=A+B
B=A+B
LOOP ctr
END Series()
Ans: Correct program
DECLARE SUB Series()
CLS
CALL Series
END
SUB Series
A=2
B=2
FOR ctr= 1 to 5
PRINT A;B;
A=A+B
B=A+B
NEXTctr
END SUB
12. Write the output of the following program.
DECLARE FUNCTION Interest(p,t,r)
CLS
LET p=30
LET t=40
LET r=6
LET d=Interest(p,t,r)
PRINT “The simple interest will be”; d
END
FUNCTION Interest(p,t,r)
answer = (p*t*r)/100
Interest=answer
END FUNCTION
Ans: Output
The simple interest will be 72
13. Analyse the program given below and answer the questions:
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?
Ans: If the user enters 200 as the first number and 100 as the second number, the output will be:
The difference of the two number= 100
b) Will the program run if the first line (i.e. DECLARE…..) is deleted?
Ans: Yes, the program will run if the first line (i.e. DECLARE……) is deleted.
DECLARE SUB Series()
CLS
EXECUTE Series
END
SUB Series
A=2
B=2
FOR ctr= 1 to 5
DISPLAY A;B;
A=A+B
B=A+B
LOOP ctr
END Series()
Ans: Correct program
DECLARE SUB Series()
CLS
CALL Series
END
SUB Series
A=2
B=2
FOR ctr= 1 to 5
PRINT A;B;
A=A+B
B=A+B
NEXTctr
END SUB
12. Write the output of the following program.
DECLARE FUNCTION Interest(p,t,r)
CLS
LET p=30
LET t=40
LET r=6
LET d=Interest(p,t,r)
PRINT “The simple interest will be”; d
END
FUNCTION Interest(p,t,r)
answer = (p*t*r)/100
Interest=answer
END FUNCTION
Ans: Output
The simple interest will be 72
13. Analyse the program given below and answer the questions:
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?
Ans: If the user enters 200 as the first number and 100 as the second number, the output will be:
The difference of the two number= 100
b) Will the program run if the first line (i.e. DECLARE…..) is deleted?
Ans: Yes, the program will run if the first line (i.e. DECLARE……) is deleted.
No comments:
Post a Comment