I am writing in C ++. The task is to calculate the values of a function using a random number generator. E <= - 0.02 a F <= 0.02. When I open the file, it is empty. Tell me what the error is.
#include <iostream> #include <stdio.h> #include <math.h> #include <cstdlib>
using namespace std; int main () { float t=0, b=0, c=0; bool E[1]={}, F[1]={}; char d = ';'; int i=0; FILE *file; file = fopen("kola.csv", "w+"); while (i<=1001) { E[i]=rand()<=(-0.02); F[i]=rand()<=(0.02); t=t+0.01; b=cos(t+E[i]); c=0.5*t*cos(t+F[i]); fprintf (file, "%f%c%f\n",b,d,c); i++; } fclose(file); return 0; }