Welcome to Pete's QBASIC Site!

Why are the "random numbers" generated with RND always the same?

No "random numbers" generated by a computer are ever truly random, since they're chosen from a pre-determined set. That's why QBasic will always pick the same numbers with the RND command.

However, there is a way to work around this: Include the statement RANDOMIZE TIMER somewhere before the RND function in your program. This makes QBasic adjust its random number set based on the computer's internal TIMER. Since the TIMER is constantly changing, so will your random numbers.

Submitted by: Pete on June 22, 2004

Return to the FAQ

Copyright © Pete's QBASIC / QuickBasic Site, 1998-2018.
All rights reserved. Site owned and operated by Pete Berg. Programs and submitted content are property of their creators, and appear on this site by direct or implied permission. Pete's QBasic Site is powered by Coranto. This site was created entirely in Notepad.