Question: An array of prime numbers 2 - 4 9 9 is stored in a file primeNumbers txt . This program can allow to request
An array of prime numbers is stored in a file "primeNumbers txt This program can allow to request a number from the user and find the closest prime number to the input number either higher or lower and print the lower one if the number is in the middle of two.
Your program should run interactively until the user quits. Try to minimize the program execution time by using the appropriate searching method for finding the prime numbers You need to record and report the number of comparisons executed for finding the prime numbers.
Sample Output
Enter a number between and
This number is outside the accepted range.
Do you want to continue
Enter a number between and :
The closest prime is:
The number of comparisons is:
Do you want to continue
Enter a number between and :
The closest prime is
The number of comparisons is:
Do you want to continue
Enter a number between and :
The closest prime is:
The number of comparisons is:
Do you want to continue
Goodbye!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
