To accept 10 different numbers with array variable and print the greatest number.
CLS
DIM n(10)
FOR i = 1 TO 10
INPUT "Enter the numbers"; n(i)
NEXT i
FOR j = 1 TO 10
FOR k = 1 TO 10 - j
IF n(k) < n(k + 1) THEN
SWAP n(k), n(k + 1)
END IF
NEXT
NEXT
PRINT "The greatest number is "; n(k)
END
Using READ DATA
CLS
DIM n(10)
FOR i = 1 TO 10
INPUT "Enter the numbers"; n(i)
NEXT i
FOR j = 1 TO 10
FOR k = 1 TO 10 - j
IF n(k) < n(k + 1) THEN
SWAP n(k), n(k + 1)
END IF
NEXT
NEXT
PRINT "The greatest number is "; n(k)
END
Using READ DATA
- CLS
DIM n(10)
FOR i = 1 TO 10
READ n(i)
NEXT i
FOR j = 1 TO 10
FOR k = 1 TO 10 - j
IF n(k) < n(k + 1) THEN
SWAP n(k), n(k + 1)
END IF
NEXT
NEXT
PRINT n(k)
DATA 1,5,7,55,9,8,17,35,50,22
END