Page 1 of 1

Small problem in a small program

Posted: Sun Jan 16, 2011 11:43 am
by Nexgen
Why does work the code below, the compiler tell me it`s a problem whit array n(i). I really can not see the problem.
I usigng QB64.

Code: Select all

DIM num AS STRING
DIM nrnot AS INTEGER
DIM n(i) AS INTEGER
DIM sum AS INTEGER
INPUT "Numele: "; num
PRINT "Nr de note pentru studentul "; num; ":";
INPUT nrnot
FOR i = 1 TO nrnot
    IF i = 1 THEN
        PRINT "Introdu prima nota: "
        INPUT n(i)
    ELSE
        PRINT "Introdu a- "; i; "-a nota:"
        INPUT n(i)
    END IF

    sum = sum + n(i)

NEXT i
med = sum / nrnot
PRINT "Media este:"
IF med < 5 THEN
    COLOR 4
    PRINT med
ELSEIF med = 5 THEN
    COLOR 2
    PRINT med
ELSE
    COLOR 1
    PRINT med

END IF
COLOR 0
Sorry for my english!

Posted: Sun Jan 16, 2011 8:54 pm
by burger2227
i = 0 when the program starts so you are making an array with 0 elements. Put the number of the elements the program will need in there.

Ted