/****************************************************************/
/* Module : test_random.c        			        */
/* Section: 13.1			                        */
/* Cheney-Kincaid, Numerical Mathematics and Computing, 5th ed, */
/* Brooks/Cole Publ. Co.                                        */
/* Copyright (c) 2003.  All rights reserved.                    */
/* For educational use with the Cheney-Kincaid textbook.        */
/* Absolutely no warranty implied or expressed.                 */   
/* 								*/
/* Description: Example to compute and print n random numbers   */
/*								*/
/****************************************************************/

/*****************************************************************/
/* The value of RAND_MAX used in these programs may not be the same on
/* different platforms/compilers. It is at least 32767. One may want to check
/* this value (the definition of RAND_MAX) on the compiler of one's choice 
/* before compiling and executing the program.
/****************************************************************/

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

#ifndef RAND_MAX
#define RAND_MAX 2147483648
#endif

#define n 10

void main()
{
  double X[n+1];
  int i;

  srand(time(NULL)); /* use a random seed */
  for (i = 1; i <= n; i++)
  {
    X[i] = (float) rand() / (float) RAND_MAX;
    printf("X[%d] = %f\n", i, X[i]);
  }

}
