logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Writer CenterAccounting
(5/5)

920 Answers

Hire Me
expert
Santosh SaxenaComputer science
(5/5)

692 Answers

Hire Me
expert
Bruce BachinskyyScience
(5/5)

641 Answers

Hire Me
expert
Imraan KhanManagement
(5/5)

572 Answers

Hire Me
C++ Programming

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.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme