I making a program. I know most of it just need help with the number generator. I want it to occur the number of times inputted.

Recommended Answers

All 3 Replies

.Net has a class for that.

Random ran = new Random();
int i = ran.Next(10);  //This will make i an integer between 0 and 9

for (int x = 0; x < i; x++)
   //Do stuff

Hope this helps!

You could do.

Random randomNumGenerator = new Random();

to make it occur a lot of times

for (int i = 0; i <=15; i++)
    random = randomNumGenerator.Next(1,7)
    numOccurrance[random]++//stores it in an array

Who downvoted me twice over my post, then upvoted the guy that said the exact same thing right after I did despite the fact that he didn't even put curly braces around his for loop therefore causing numOccurance to only get incremented once at one index?? The humanity!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.