[Webinar] Streamline your web hosting managementRegister Today


Random generator

Posted on 2000-01-07
Medium Priority
Last Modified: 2010-04-15

I need to generate random numbers between 1 and 200 ( all integers ).. Is there an easy way to do that.. I know bout the rand function, but how can u force it to generate numbers in [1-200].

Question by:Kro
1 Comment

Accepted Solution

marcjb earned 200 total points
ID: 2332301
number = (rand() % 200) + 1;

NOTE:  rand() % 200 will return numbers from 0-199, so you add 1.

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question