Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

=+c. how to find an online discussion board and subscribe to it

Answered: 1 week ago