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];

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)
else
}

printf("\n");
for (ttt = 0; ttt < generations; ttt++)
printf("\n%f", mom_gene[ttt]);
}

return;
}

main()
{

//int seed = 456739853;
//  srand48(time(NULL));

populate(10);
}``````

I think I found my bug
here is the fixed code

``````#include <stdio.h>
#include <stdlib.h>
// int ttt;

void populate(int generations)
{

int seed, ttt;
seed = 456739853;
srand48(seed);

double r;
double mom_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", drand48());
printf("\n");
//  printf("time\tpopSize\n");
for (ttt = 0; ttt < generations; ttt++)
{

r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );

if(r < 0.1)
{ mom_gene[ttt] = r;}
else
{ mom_gene[ttt]= -r;}
//    printf("\n %f", mom_gene[ttt]);
}

for (ttt = generations; ttt > 0; ttt--)
{
r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
if(r < 0.1)
else
}

printf("\n");
for (ttt = 0; ttt < generations; ttt++)
printf("\n %f", mom_gene[ttt]);
}

return;
}

int main(void)
{

//int seed = 456739853;
//  srand48(time(NULL));

populate(10);
return 0;
}``````