Type Conversion

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cstdlib>
#include <windows.h>
#define TAM 20
#define PI 3.14159265
#define myrand (double) rand () / (double) RAND_MAX

int main(){
srand(time(NULL));
double u1[TAM], u2[TAM], z1[TAM], z2[TAM] ;
int i;
for(i=0; i<TAM; i++){
u1[i] = rand();
u2[i] = rand();
z1[i] = ((sqrt(-2*log(u1)))*cos(2*PI*u2)); //Error is here
z2[i] = ((sqrt(-2*log(u2)))*cos(2*PI*u1));
printf("\n%f ", u1);
printf("\n%f ", u2);
// Sleep(1000);
}
system("pause");
return 0;

}
Questao2.cpp:18: error: cannot convert 'double*' to 'double' for argument '1' to 'double log(double)'

How should I proceed?

Tks!
u1 and u2 are an array of TAM (20) doubles. You must work on each one individually;

z1[i] = ((sqrt(-2*log(u1[i])))*cos(2*PI*u2[i]));
Thank you!!
Topic archived. No new replies allowed.