English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

could someone type out a simple operation program providing me with a random (or as close as a computer can get to being random) number between 1 and 10. Thanks, I learned basic more than 17 years ago and am an artist working on a project in which I am using random machine output to affect my color choices in drawings... thanks a ton....

2007-04-25 01:49:18 · 5 answers · asked by quintstevenson 3 in Computers & Internet Programming & Design

i am using chipmunk basic, which is apple basic for mac os x...

2007-04-25 01:58:09 · update #1

thanks guys... got that output going alright...

2007-04-25 02:17:36 · update #2

5 answers

i know that in qbasic it would be

randomized timer

x=int(rnd*10)+1

print X


the randomized timer is what makes it random. otherwise everytime you restart the program, you'll get the same random numbers because it would be using the same seed.

i don't know if it is the same for your version. check the help file.

2007-04-25 02:34:27 · answer #1 · answered by Anonymous · 0 0

I wouldn't say there's a better programming language. Visual Basic is pretty good, but it doesn't get you familiarized with anything beyond basic programming concepts. C# and Java are based on the same principles, but Java is more portable as it works on any operating system, while C# will work only on Windows. However, the Integrated Development Environment (IDE) you have for C#, Visual Studio, is absolutely superb to use. I'd recommend learning either Java or C#. Once you know one of them, it's easy to learn other other. Good Luck!

2016-05-18 02:38:34 · answer #2 · answered by lauri 3 · 0 0

I remember Applesoft BASIC.
You'll need to find a reference guide for your version of BASIC for the random number creation instruction.

I don't know if the format is the same with your version of BASIC, but Applesoft's random number generator worked like this:

x=int(rnd(0)*10)+1
x = integer from 1 to 10

x=int(rnd(0)*400)+40
x = integer from 40 to 400

x=(rnd(0)*30)
x = floating point number from 0 to 30

2007-04-25 02:05:21 · answer #3 · answered by Balk 6 · 0 0

The function "RND" with an integer value greater than one, returns an integer value between 0 and one less than that number.

So, if you want 10 different values, RND(10) will return a random integer between 0 and 9. Since you want 1 to 10, just add one to that.

The program you want is one line long:

===================
PRINT RND(10)+1
===================

2007-04-25 02:02:30 · answer #4 · answered by McFate 7 · 0 0

if you have a TI-83 graphing calculator
create a new program
{
ClrScreen
randInt(1,10,A)
Output(1,1,A)
pause
ClrScreen
}
where all the stuff inside of the brackets is the code
then just run the program, voila

2007-04-25 01:56:03 · answer #5 · answered by jlp.media 3 · 0 0

fedest.com, questions and answers