Question: C++ Help- practice using loops and if statements. I need to write a prime test program. In order to check if a number is prime,

C++ Help- practice using loops and if statements. I need to write a prime test program. In order to check if a number is prime, use a loop to try dividing the users number by each number between 2 and the number provided. If any of the numbers between 2 and the users number divides their number, then it is not prime. If none of the numbers divides their number, then it is prime. Do not bother dividing the users number by itself since that will always give 1. I have this so far:

#include  using namespace std; int main() { int usrNumber; bool isPrime = true; cout << "============PRIME TESTER============" << endl; cout << "What number would you like to test? > "; cin >> usrNumber; // Implement a prime test here. return 0; } 

*Expected Output 1 (user input in italics)

============PRIME TESTER============

What number would you like to test? > 1

The number 1 is neither Prime nor Composite.

*Expected Output 2

============PRIME TESTER============

What number would you like to test? > 11

The number 11 is Prime.

*Expected Output 3

============PRIME TESTER============

What number would you like to test? > 4

The number 4 is not prime.

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!