I cant seem to figure out whats wrong with this code, I am trying to generate random floating point number numbers with values from 0 to 1 with positive and negative values
here is the code
#include <stdio.h>
#include <stdlib.h>
void populate(int generations)
{
int seed, ttt;
seed = 456739853;
srand48(seed);
int mom_gene[generations];
int dad_gene[generations];
float y;
y= (drand48()/10.0);
//float x;
//x=(y/10.0);
printf("\n Here are the values of rand and y, %f, %f", drand48(), y);
printf("\n");
// printf("time\tpopSize\n");
for (ttt = 0; ttt < generations; ttt++)
{
if(drand48()>0.50)
{ mom_gene[ttt]=drand48();}
else
{ mom_gene[ttt]=-drand48();}
// printf("\n %f", mom_gene[ttt]);
}
for (ttt = generations; ttt > 0; ttt--)
{
if(drand48()>0.50)
{ dad_gene[ttt]=drand48();}
else
{ dad_gene[ttt]=-drand48();}
// printf("\n%f", dad_gene[ttt]);
}
printf("\n");
for (ttt = 0; ttt < generations; ttt++)
{ printf("\n%f", dad_gene[ttt]);
printf("\n%f", mom_gene[ttt]);
}
return;
}
main()
{
//int seed = 456739853;
// srand48(time(NULL));
populate(10);
}