store random in array

closed account (375jz8AR)
Hi i know is c language, but i am waiting for acceptance in a forum of c language. i run this programm but it tells me that i is undefined, how cani do it to print all the random values stored in the array in the main function?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<stdlib.h>


double randf();
int main()
{
	double s;
	s=randf();
	printf("%lf", s);
	return 0;
}
double randf()
{
	
	double a = 1;
	double b = 0;
	double x[8];
	for (int i = 0; i <= 8; ++i)
	{
		srand((unsigned)time(NULL));
		x[i] = rand()*(a - b) / (double)RAND_MAX + b;

	}
		return x[i];
	
}
Topic archived. No new replies allowed.