1. Re-write the given program after correcting the bugs.
Error (bug) | Correction |
---|---|
START | CLS |
10=B | B=10 |
SUM=A-B | SUM=A+B |
THE END | END |
After correction the correct program is:
Error (bug) | Correction |
---|---|
INPUT ... N$ | N |
DO WHILE N$<>0 | DO WHILE N<>0 |
B= 10 MOD N$ | B=N MOD 10 |
R=B*10+R | R=R*10+B |
N$=N$/10 | N=N\10 |
After correction the correct program is:
Error(bug) | Correction |
---|---|
INPUT ....W | W$ |
LEN$ | LEN |
MID | MID$ |
NEXT P | NEXT I |
PRINT C$ | R$ |
After correction the correct program is:
Error (bug) | Correction |
---|---|
CASE 2,000 TO 5,000 | CASE 2000 TO 5000 |
C=(AMT*10%) | C=(AMT*10)/100 |
CASE 5001 TO 10,000 | CASE 5001 TO 10000 |
C=(AMT*100)/20 | C=(AMT*20)/100 |
ELSE CASE | CASE ELSE |
SELECT END | END SELECT |
Error (bug) | Correction |
---|---|
INPUT .... N$ | N |
S=SIGN(N$) | S=SGN(N) |
CASE S | CASE 1 |
CASE 0 | CASE ELSE |
SELECT END | END SELECT |
- Re-write
the given program after correcting the bugs.
REM to count vowels in a sentence
INPUT “Enter string ::::” ; S
L=LEN$(S)
FOR K = 1 TO L
C$=MID$(S$,1,K)
SELECT CASE C$
CASE
A,E,I,O,U
COUNT=COUNT+1
SELECT END
NEXT
PRINT
“Supplied Sentence”; S$
PRINT
“Total Vowels :::::;C
END
Answer:
Error (bug) |
Correction |
INPUT …S |
S$ |
LEN$(S) |
LEN(S$) |
C$=MID$(S$,1,K) |
MID$(S$,K,1) |
CASE A,E,I,O,U |
CASE “A”, “E”,
“I”, “O” , “U” |
SELECT END |
END SELECT |
NEXT |
NEXT K |
PRINT …C |
COUNT |
After correction the correct program is:
REM to count vowels in a sentence
INPUT “Enter string ::::” ; S$
L=LEN(S$)
FOR K = 1 TO L
C$=MID$(S$,K,1)
SELECT CASE C$
CASE
“A”, “E” , “I” , “O” , “U”
COUNT=COUNT+1
END SELECT
NEXT K
PRINT
“Supplied Sentence”; S$
PRINT
“Total Vowels :::::;COUNT
END