Tuesday, October 25, 2011

Qbasic (Enter 10 different nos. and find total and average)

DECLARE FUNCTION ARR(A())
CLS
DIM A (10)
PRINT "ENTER 10 NOS"
FOR I = 1 TO 10
INPUT A (I)
NEXT
LET SM = ARR(A())
LET AVG = SM/10
PRINT "SUM IS"; SM
PRINT "AVERAGE IS"; AVG
END

FUNCTION ARR(A())
FOR I = 1 TO 10
LET S= S+A(I)
NEXT
ARR = S
END FUNCTION

No comments:

Post a Comment