Editedcode
Editedcode
#include <stdio.h>
#include <pthread.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
// defining the total number of points from which random points are selected
//int N = 8000000;
//function to find the number of random points inside the unit circle
void * Count (void *X)
{
/* initialize random numbers */
for (int i = 0; i < N; i++)
{
double x = (double)RandUint (i);
double y = (double)RandUint (i);
srand (SEED);
// defining the thread variable as pthread_t datatype (4 bytes)
pthread_t thread;
// creating a pthread which computes the number of points inside the unit circle
pthread_create (&thread, NULL, &Count, NULL);
printf ("No of trials: %d \nNo of points inside unit circle: %d \nEst value of
pi:%lf\n",N,totalPts,estPiValue);
int main ()
{
/ defining the total number of points from which random points are selected
int N = 8000000;
char data[data_size];
FILE * fPtr;
fPtr = fopen("inp.txt", "w");
if(fPtr == NULL)
{
/* File not created hence exit */
printf("Unable to create file.\n");
exit(EXIT_FAILURE);
}
fclose(fPtr);
return 0;
}