Post a New Question

cis

posted by on .

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============

  • Computer Programming? - ,

    Please type your subject in the School Subject box. Any other words, including obscure abbreviations, are likely to delay responses from a teacher who knows that subject well.

  • cis - ,

    Error 1: (logic)
    REM Read 9 scores and report the average
    PRINT "The average score is "; Sum()/10:

    Error 2: (logic)
    Also, for the function Sum(), it should not sum over 10 elements, when only 9 are stored.


    Error 2: (syntax)
    For i = 1 to 10
    CALL fillArray
    PRINT "The average score is "; Sum()/10:
    Next j



    ?Error 3: (logic)
    Check the default type of variables.
    If sum() is integer, then Sum()/10 will lose accuracy because of the integer division.

Answer This Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Post a New Question