I did it and it workd perfectly, i add two more functions, one calculate the average value of the array and the other reverse this array, the problem is that the program does not print the reverse matrix.
Code:
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
double randf(double *p);
double average(double *k);
double reverse(double *j);
#define SIZE 8
int main()
{
double b;
srand((unsigned)time(NULL));
double arr[SIZE];
randf(arr);
b = average(arr);
printf(" average is equal to %lf\n", b);
printf("this is the reverse matrix\n");
reverse(arr);
}
double randf(double *p)
{
double a = 1;
double b = 0;
for (int i = 0; i < SIZE; ++i)
{
p[i] = rand()*(a - b) / (double)RAND_MAX + b;
printf("%lf\n", p[i]);
}
return 0;
}
double average(double *k)
{
double x = 0;
for (int i = 0; i < SIZE; ++i)
x +=(k[i])/SIZE;
return x;
}
double reverse(double *j)
{
for (int i = SIZE; i < 0; --i)
{
j[i] = rand()*(1 - 0) / (double)RAND_MAX + 0;
printf("%lf\n", j[i]);
}
return 0;
}