Write two helper functions-one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) each of which Take the array and its size as input params and return a bool.C++ Programming

Write the simplest C++ program that will demonstrate iteration vs recursion using the following guidelines - 

  1. Write two helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which
    1. Take the array and its size as input params and return a bool. 
    2. Print out a message "Entering " as the first statement of each function.
    3. Perform the code to test whether every element of the array is a Prime number.
    4. Print out a message "Leaving " as the last statement before returning from the function.
    5. Remember - there will be nested loops for the iterative function and there can be no loops at all in the recursive function. You will need to define other helper functions to make the recursive method work.
    6. Remember - replace with the actual name of each function.
    7. Hint - try to complete your iterative code first and then convert it piece by piece to the recursive code.
  2. In your main:
    1. Ask the user for the number of elements, not to exceed SORT_MAX_SIZE = 16 (validate input).
    2. Declare a dynamically allocated array of integers based on the size input provided by the user.
    3. Get the input in a loop, validating that the integers input by the user are between 1 and 99, both inclusive
    4. Make a call to the iterative function passing the array and its size.
    5. If every member is a Prime, then the program should print out 'Prime Array using iteration', otherwise print out 'Not a Prime Array using iteration'.
    6. Then make a call to the recursive function passing the array and its size.
    7. If every member is a Prime, then the program should print out 'Prime Array using recursion', otherwise print out 'Not a Prime Array using recursion'.
    8. If your functions are coded correctly, both should come up with the same answer, except you should have lots more output statements using recursion.
    9. Remember to delete your array before the program exits.
  3. There will be only one code file called Lab.cpp in your program.
  4. Remember to take multiple screenshots so that they are clearly readable without needing to zoom in.
  5. For documentation, including your name block as well pre/post and pseudocode for the two functions.
  6. Upload your code file and the screenshots in one zip file. Do not include anything else.

 

Grading:

  • 25 pts - EXE works from as explained above without needing any code change
  • 10 pts - for the main
  • 15 pts - the IsArrayPrimeIter function
  • 25 pts - the IsArrayPrimeRecur function
  • 25 pts - following all instructions in Lab - General Submission Instructions carefully
  1. Not including screenshots will result in a 10% penalty.
  2. Not including pseudocode will result in a 20% penalty.
  3. Not including pre/post headers will result in a 20% penalty.

Expert's Answer

OR

C++ Programming Experts

expert
Dinh Hong P.
C++ Programming

20 Answers

expert
Eric Bell
C++ Programming

88 Answers

View More Experts
Disclaimer

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

252 Experts Online