Question: I need help trying to match my output ( black ) with the correct output ( white ) using my code in C . Primes.c

I need help trying to match my output(black) with the correct output(white) using my code in C.
Primes.c
#include
#include
#include
#include "Primers.h"
int random_in_range(int lower_bound, int upper_bound)
{
return ((rand()%(upper_bound - lower_bound))+ lower_bound);
}
void populate(int *arr, int size, int lower_bound, int upper_bound)
{
for(int i=0; i max){
max = curr;
}
}
return max;
}
float get_running_ratio()
{
float sumRatio =0;
int maxPrimes =0;
int iteration_number =1;
int num_iteration = random_in_range(50,100);
for (int j =0; j num_iteration; j++)
{
int size = random_in_range(150,201);
char *arr =(char *)malloc(sizeof(char)* size);
for (int i =0; i size; i++)
{
arr[i]= random_in_range(50,200);
}
int primeCount = get_prime_count(arr, size);
float ratio =(float)primeCount /(float)(size - primeCount);
sumRatio += ratio;
if (maxPrimes primeCount)
{
maxPrimes = primeCount;
iteration_number = j;
}
free(arr);
}
printf("[Primes]: Number of iterations is: %d
", num_iteration);
printf("[Primes]: Iteration with MAX prime count: %d
", iteration_number);
return (sumRatio / num_iteration);
}
Drivers.c
#include "Primes.c"
#include
#include
int main(int argc, char**argv)
{
int seed =0;
if (argc >1){
seed = atoi(argv[1]);
} else{
seed =1000;
}
printf("[Driver]: Seeding RNG with seed: %d
", seed);
srand(seed);
float avgRatio = get_running_ratio(0);
printf("[Driver]: Average prime/composite ratio: %f
", avgRatio);
return EXIT_SUCCESS;
}
I need help trying to match my output ( black )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!