6.
Re-write the given program after correcting the bugs: [2]
REM to add record in an existing file
CLS
OPEN “[Link]” FOR OUTPUT AS #1
AA:
INPUT “Enter Name, Class and Roll No.”; Nm$, Cl, Rn
INPUT #2, Nm$, Cl, Rn
INPUT “More records”; Y$
IF UCASE$(Y$)=”Y” THEN GOTO aa
CLOSE “[Link]”
END
Debugged program:
REM to add record in an existing file
CLS
OPEN “[Link]” FOR APPEND AS #1
AA:
INPUT “Enter Name, Class and Roll No.”; Nm$, Cl, Rn
WRITE #1, Nm$, Cl, Rn
INPUT “More records”; Y$
IF UCASE$(Y$)=”Y” THEN GOTO AA
CLOSE #1
END
6. Re-Write the given program after correcting the bags:
REM to display name, post and salary of 10 employees
OPEN "[Link]" FOR IN AS #1
FOR I=10 TO 1
INPUT #1, Name$, Post$, Salary
DISPLAY Name$, Post$, Salary
NEXT I
CLOSE “[Link]”
END
Corrected Program:
REM to display name, post and salary of 10 employees
OPEN "[Link]" FOR INPUT AS #1
FOR I=1 TO 1 0
INPUT #1, Name$, Post$, Salary
PRINT Name$, Post$, Salary
NEXT I
CLOSE #1
END
6. Re-Write the given program after correcting the bugs:
DECLARE SUB Square (A)
REM to print square of a input number
CLS
GET "Enter a number"; N
Square (N)
END
SUB Square (A)
Sq = A^ 4
Display "Square of a number is "; Sq
End Sub
Debugged Program
DECLARE SUB Square (A)
REM to print square of a input number
CLS
INPUT "Enter a number"; N
CALL Square (N)
END
SUB Square (A)
Sq = A^ 2
PRINT "Square of a number is "; Sq
End SUB
6. Re-Write the given program after correcting the bugs:
REM program to make a word reverse
DECLARE FUNCTION Rev$(N$)
CLS
LNPUT “Enter a word”; N$
DISPLAY “Reversed is”; Rev$(N$)
END
EUNCTION Rev$(N$)
FOR K=LEN$(N$) To 1 STEP-1
B$=B$+MID$(N$,1,K)
NEXT K
B$=Rev$
END FUNCTION
Debugged Program
REM program to make a word reverse
DECLARE FUNCTION Rev$(N$)
CLS
INPUT “Enter a word”; N$
PRINT “Reversed is”; Rev$(N$)
END
FUNCTION Rev$(N$)
FOR K=LEN (N$) To 1 STEP-1
B$=B$+MID$(N$,K,1)
NEXT K
Rev$=B$
END FUNCTION
Rewrite the given program after correcting the bugs:
REM to display records from existing file.
OPEN "[Link]" FOR APPEND AS #1
WHILE NOT EOF (#1)
WRITE # 1, eN$, posts, salaryS
PRINT eN$, post$, salary
NEXT
CLOSE #1
END
Debugged Program
REM to display records from existing file.
OPEN "[Link]" FOR INPUT AS #1
WHILE NOT EOF (1)
INPUT # 1, eN$, posts, salary$
PRINT eN$, post$, salary
WEND
CLOSE #1
END
6. Re-write the given program after correcting the bugs: 2
REM to display records from existing file.
CLS
OPEN “[Link]” FOR APPEND AS #1
WHILE NOT EOF(#1)
WRITE #1, eN$, post$, salary
PRINT eN$, post$, salary
CLOSE#1
END
Debugged Program
REM to display records from existing file.
CLS
OPEN “[Link]” FOR INPUT AS #1
WHILE NOT EOF(1)
INPUT #1, eN$, post$, salary
PRINT eN$, post$, salary
WEND
CLOSE #1
END
6. Re-write the given program after correcting the
bug. [2]
FUNCTION SUM(M, N)
REM to print sum of two numbers
A=6
B=7
DISPLAY sum(M,N)
END
FUNCTION SUM(M,N)
S=M+N
S=SUM
END FUNCTION
Debugged Program
DECLARE FUNCTION SUM(M, N)
REM to print sum of two numbers
A=6
B=7
PRINT sum(A,B)
END
FUNCTION SUM(M,N)
S=M+N
SUM=S
END FUNCTION