Filling an array with random numbers
Ok, another week, another assignment, another question
I'm trying to write a program that will track a share price, and to do so need to fill an array with random fluctuations, say 0.5 either side of the startPrice (which the user will supply)..
I am not sure how to fill an array with random numbers, so far i have
Code:
int prices[]; //declare array (not sure how big yet)
int numDays, i;
float firstEntry, startPrice;
Printf ("Please enter the starting price of the share you wish to track: ");
scanf ("%d", &startPrice );
prices[0]= startPrice;
for (i=1; i < numdays; i++)
{
prices[i] = startPrice - 0.5 + rand() % startprice + 1.5; //generates prices for share
}
will this do the job?
Thanks!