int main int x 10 y 20 cout Before swap1 x y x y endl swap1 x y cout After

# Int main int x 10 y 20 cout before swap1 x y x y endl

• Lab Report
• 11

This preview shows page 9 - 11 out of 11 pages.

Question:Which swapping function(s), swap1, swap2 or swap3 does (do) the job correctly?
Division of Applied Science and Technology, Community College of City University AST21105 Object-Oriented Programming & Design Page 10 of 11 D.Find Prime Numbers In this part, you are required to:i)Create a New Project and give your project the name Lab4b. ii)Add a source file to your project, called FindPrimeNumbers.cpp iii)Write a C++ program that uses an array of n elements (where n is a user input) to determine and display the prime numbers between 2 and n using the method described below. Ignore array elements 0 and 1. A prime number is any integer greater than one that is divisible only by itself and 1. A list of prime numbers can be found by the following method. a) Create a primitive type boolarray with all elements initialized to true. Array elements with prime b) Starting with array index 2, determine whether a given element is true. If so, loop through the d) When this process completes, the array elements that are still true indicate that the index is a prime number. These indices can be displayed. Multiple sessions of sample screen display when the method is called are given below:Enter the value of n: 10Prime numbers: 2, 3, 5, 7 4 primes found.Enter the value of n: 60Prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 5917 primes found.
Division of Applied Science and Technology, Community College of City University AST21105 Object-Oriented Programming & Design Page 11 of 11 Enter the value of n: 100Prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 9725 primes found.The input which is underlined is the user’s input to a question. (Note: you don’t have torepeatedly execute your program code using loop for this assignment)iv)Compile your program and test it by executing your program. Marking Scheme: Graded items Weighting 1.Correctness of program (i.e. whether your code is implemented in a way according to the requirements as specified.) 60% 2.Indentation 30% 3.Documentation (with reasonable amount of comments embedded in the code to enhance the readability.) 10% 100% Program Submission Checklist Before submitting your work, please check the following items to see you have done a decent job. Items to be checked / 1.Did I put my name and student ID at the beginning of all the source files? 2.Did I put reasonable amount of comments to describe my program? 3.Are they all in .cpp extension and named according to the specification? 4.Have I checked that all the submitted code are compliable and run without any errors? 5.Did I zip my source files using Winzip / zip provided by Microsoft Windows? Also, did I check the zip file and see if it could be opened? (Only applicable if the work has to be submitted in zip format.)6.Did I submit my lab assignment to Canvas? -End-