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 -
- 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.
- Print out a message "Entering " as the first statement of each function.
- Perform the code to test whether every element of the array is a Prime number.
- Print out a message "Leaving " as the last statement before returning from the function.
- 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.
- Remember - replace with the actual name of each function.
- Hint - try to complete your iterative code first and then convert it piece by piece to the recursive code.
- In your main:
- Ask the user for the number of elements, not to exceed SORT_MAX_SIZE = 16 (validate input).
- Declare a dynamically allocated array of integers based on the size input provided by the user.
- Get the input in a loop, validating that the integers input by the user are between 1 and 99, both inclusive
- Make a call to the iterative function passing the array and its size.
- 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'.
- Then make a call to the recursive function passing the array and its size.
- 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'.
- If your functions are coded correctly, both should come up with the same answer, except you should have lots more output statements using recursion.
- Remember to delete your array before the program exits.
- There will be only one code file called Lab.cpp in your program.
- Remember to take multiple screenshots so that they are clearly readable without needing to zoom in.
- For documentation, including your name block as well pre/post and pseudocode for the two functions.
- 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
- Not including screenshots will result in a 10% penalty.
- Not including pseudocode will result in a 20% penalty.
- 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