Question: our goal is to write a program to find good prime numbers using the sieve of Eratosthenes. A good prime number is a number which:
our goal is to write a program to find good prime numbers using the sieve of Eratosthenes. A
good prime number is a number which:
Is a prime number
Is between a given lower and upper bound
Does not contain a given digit
Problem
You are to create a C project called sieve, a C source file called sieve.cpp and struct inside it
called PrimesEratosthenesSieve that finds good prime numbers. The program asks the user for a
lower bound, an upper bound, and a bad digit, and then finds good primes which are greater than
or equal to the lower bound and less than or equal to the upper bound and do not contain the bad
digit. When there is only one line of good prime numbers in the output, the numbers should be
displayed with one space between each and no space at the end When there are multiple lines of
output, the numbers should be rightaligned to the width of the largest good prime. See below.
Tips
Use the template file found in Canvas. The framework for the program is there, and you will
need to fill in the methods. You MUST use the given members and methods to solve the
problem.
You MUST dynamically allocate the primes bool array. Dont forget to free any dynamically
allocated memory.
If a functionmethod is inline, the compiler places a copy of the code of that
functionmethod at each point where it is called at compile time. inline is used for efficiency
with short oneline functionsmethods
Look up setw in the iomanip library to set the width of a field that is to be outputted.
#include for the sqrt function.
You may have up to characters on a line. If you cannot fit all the primes on one line, you
should wrap around to the next line. To find the width of the maximum prime value and how
many primes you can fit on a row, use the following code:
const int maxprimewidth numdigitsmaxprime;
const int primesperrow maxprimewidth ;
Be sure to comment your code and put your name and Stevens pledge at the top.
Make sure your code works with the test script.
The algorithm for the sieve is found in the pseudocode below
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
