We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

# Random generator?

on
Medium Priority
290 Views
I have these lines:

x = rnd(0, max);
y = rnd(0, max);

max is 99 right now, but could, of course, be changed to
whatever I need at the moment.

What I would like is for someone to make me the rnd function.
It should generate different numbers every time, or at least
as often as possible.

So what I really need is a function that can generate a random
number between 0 and max.

I hope you can help me!

Regards,

Comment
Watch Question

## View Solution Only

Commented:

Commented:
increase the points and I can write you one.
Commented:
//Use the randomize() with rand() Function

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(void)
{
int i;

randomize();
printf("Ten random numbers\n\n");
for(i=0; i<10; i++)
printf("%d\n", rand() % 150); //change the 150
return 0;
}

Not the solution you were looking for? Getting a personalized solution is easy.

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile