11-06-2024, 11:15 PM
Hello
can someone tell me why this little program will not work i dont really understand why.
badger
thanks in advance
can someone tell me why this little program will not work i dont really understand why.
badger
thanks in advance
Code: (Select All)
DECLARE SUB GenerateUniqueNumbers()
DIM numbers(5) AS INTEGER
DIM count AS INTEGER
DIM i AS INTEGER
DIM newNumber AS INTEGER
DIM isDuplicate AS INTEGER
SUB GenerateUniqueNumbers
count = 0
DO
' Generate a random number between -1 and 71
newNumber = INT(RND * 73) - 1
isDuplicate = 0
' Check if the number is already in the array
FOR i = 1 TO count
IF numbers(i) = newNumber THEN
isDuplicate = 1
EXIT FOR
END IF
NEXT i
' If it's not a duplicate, add it to the array
IF isDuplicate = 0 THEN
count = count + 1
numbers(count) = newNumber
END IF
LOOP UNTIL count = 5
' Print the selected numbers
PRINT "The 5 unique numbers are:"
FOR i = 1 TO 5
PRINT numbers(i)
NEXT i
END SUB
' Seed the random number generator
RANDOMIZE TIMER
' Call the subroutine to generate and display the numbers
GenerateUniqueNumbers