Asked by ami
I have to find three errors and ther two logic and syntax error. HELP ME IN IT AND Below is code.
Rem ===========BEGIN SAMPLE CODE============
REM Read 9 scores and report the average
Dim score(10)
For i = 1 to 10
CALL fillArray
PRINT "The average score is "; Sum()/10:
Next j
End
SUB fillArray
count = 0
For i = 1 to 10
READ datum
if datum > 0 then score(i) = datum
if datum = -1 then
exit sub
end if
count = count + 1
PRINT count, datum
Next i
DATA 85, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 84, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 83, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 82, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 81, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 79, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 78, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 77, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 76, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 75, 92, 68, 84, 86, 94, 74, 79, 88, -1
END SUB
FUNCTION Sum()
total = 0
FOR i = 1 TO 10
LET total = total + score(i)
NEXT i
Sum = total
END FUNCTION
Rem ===========END SAMPLE CODE============
Rem ===========BEGIN SAMPLE CODE============
REM Read 9 scores and report the average
Dim score(10)
For i = 1 to 10
CALL fillArray
PRINT "The average score is "; Sum()/10:
Next j
End
SUB fillArray
count = 0
For i = 1 to 10
READ datum
if datum > 0 then score(i) = datum
if datum = -1 then
exit sub
end if
count = count + 1
PRINT count, datum
Next i
DATA 85, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 84, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 83, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 82, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 81, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 79, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 78, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 77, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 76, 92, 68, 84, 86, 94, 74, 79, 88, -1
DATA 75, 92, 68, 84, 86, 94, 74, 79, 88, -1
END SUB
FUNCTION Sum()
total = 0
FOR i = 1 TO 10
LET total = total + score(i)
NEXT i
Sum = total
END FUNCTION
Rem ===========END SAMPLE CODE============
Answers
Answered by
Writeacher
Please type your <u>subject</u> in the <b>School Subject</b> box. Any other words, <u>including obscure abbreviations</u>, are likely to delay responses from a teacher who knows that subject well.
Answered by
MathMate
Error 1: (logic)
REM Read <i>9</i> scores and report the average
PRINT "The average score is "; Sum()/<i>10</i>:
Error 2: (logic)
Also, for the function Sum(), it should not sum over 10 elements, when only 9 are stored.
Error 2: (syntax)
For <b>i</i> = 1 to 10
CALL fillArray
PRINT "The average score is "; Sum()/10:
Next <i>j</b>
?Error 3: (logic)
Check the default type of variables.
If sum() is integer, then Sum()/10 will lose accuracy because of the integer division.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.