0

Possible Duplicate:
In C, how do I get a specific range of numbers from rand()?

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

int main(int argc, char** argv) {


srand(time(NULL));
int r = rand();

printf("%d\n", r);

return (EXIT_SUCCESS); }

i have this code and i want to make random numbers from 1-6 and fill with them a board [40] any ideas?

Community
  • 1
  • 1
John Smith
  • 43
  • 1
  • 7

1 Answers1

0
int main(int argc, char** argv) {
    int i;
    int array[40];
    srand(time(NULL));
    for (i=0; i<40; i++)
        array[i] = rand()%6 + 1
    return (EXIT_SUCCESS);  
}
waitingkuo
  • 89,478
  • 28
  • 112
  • 118