Question: Please use comments for each code block and read the hints. Question 1 of 2. Test for Primes: [50 marks] Write a C++ program which

Please use comments for each code block and read the hints.

Please use comments for each code block and read the hints. Question

1 of 2. Test for Primes: [50 marks] Write a C++ program

Question 1 of 2. Test for Primes: [50 marks] Write a C++ program which will ask the user to input an integer number and test if it is a prime number A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. Some prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, ... Make sure your code works for any input number, not just the test cases. Your code will be tested on other test cases not listed here. Please properly comment your code before submission. Sample Test cases: Test case 1: Input: Enter the first number: 8 Test case 2: Input: Enter the first number: 29 Output: Prime ?: False Output: Prime ?: True Test case 3: Input: Enter the first number: 100 Test case 4: Input: Enter the first number: 97 Output: Prime ?: False Output: Prime ?: True HINTS: Think about the problem before you start coding. We need to test if the input integer is divisible by any number up to the input integer. We need to use loops, and test divisibility for all the numbers up to the input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!