I am very new to C and have been tasked to produce a program that generates 1000 random numbers (with a max of 9) and then finds the total average. I have produced the following but it only seems to return 0 as the answer.
Code:
// Program to determine the mean of 1000 random numbers //
// written by Kerim Morris 01/10/2010 //
#include <stdlib.h>
int max_count = 1000; //declare the variables//
int count = 0;
int random_number = 0;
int random = 0;
int random_total = 0;
float mean = 0;
main() //start of main function//
{
{
for (count = 0; count < max_count; count ++); //loop counter to a maximum//
//of 1000 //
random_number = (int)(10.0*rand()/(RAND_MAX+1.0)); //produce random//
// numbers between 0-9//
random_total = random_number + random_total; //calculate the running //
// total//
}
mean = (random_total / max_count); //calculate mean of total //
printf("The mean of 1000 random numbers equals %f");
}
Any guidance would be appreciated.