rand : rand « stdlib.h « C Tutorial






ItemValue
Header filestdlib.h
Declarationint rand(void);
Functiongenerates a sequence of pseudorandom numbers. Each time it is called, an integer between zero and RAND_MAX is returned. RAND_MAX will be at least 32,767.


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

  int main(void)
  {
    int i;

    for(i=0; i<10; i++){
      printf("%d \n", rand());
    }

    return 0;
  }
262236772
208042609
800207362
428428949
47718728
1793958355
1543227091
1255063701
1245922717
448084510








23.24.rand
23.24.1.rand
23.24.2.Seed a random number