//========================================================= file = lec5.c ===== //= A program to plot a histogram of a random number generator = //============================================================================= //= Build: bcc32 lec5.c, cl lec5.c, gcc lec5.c = //=---------------------------------------------------------------------------= //= History: KJC (05/29/11) - Refresh from old version = //============================================================================= //----- Include files --------------------------------------------------------- #include // Needed for printf() #include // Needed for rand() and RAND_MAX //----- Include files --------------------------------------------------------- #define NUM_BINS 20 // The number of bins in the histogram #define NUM_SAMPLES 2000000 // The number of samples to test //===== Main program ========================================================== void main(void) { double z; // Uniform random number from 0 to 1 int histo[NUM_BINS]; // Histogram array int bin_num; // Bin number for histogram int i; // Loop counter // Initialize the histogram to all zero for (i=0; i