ARRAY in QBASIC

array in qbasic
Greatest among 5 numbers using Array

CLS

DIM num(4)

PRINT "Enter any any 5 numbers"

FOR j = 0 TO 4

     INPUT num(j)

NEXT j

lrg = num(0)

FOR j = 0 TO 4

     IF lrg > num(j) THEN

          lrg = num(j)

     END IF

NEXT j

PRINT "largest number is="; lrg

END


Input Name and Marks and Display using Array

CLS
DIM n$(5)
DIM m(5)
PRINT "Enter Name and Marks of any 5 students"
FOR i = 1 TO 5
PRINT i
INPUT "Enter Name: "; n$(i)
INPUT "Enter Marks:"; m(i)
NEXT i
PRINT
PRINT
PRINT
PRINT "MARKS OF STUDENTS"
PRINT "NAME", "MARKS", "RESULT"
FOR i = 1 TO 5
IF m(i) >= 40 THEN
r$ = "PASSED"
ELSE
r$ = "FAILED"
END IF
PRINT n$(i), m(i), r$
NEXT i
END


Display Name and Roll using READ DATA

DIM n$(6), roll(6)
CLS
FOR i = 0 TO 6
READ n$(i), roll(i)
NEXT i
FOR i = 0 TO 6
PRINT n$(i), roll(i)
NEXT i
DATA Ganesh,2,Adit,5,Dilip,3,Shailesh,8,Lal,9,Bishal,10,laxman,11
END

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image