Assume that you are given a function bool isPrimeint a that

Assume that you are given a function bool isPrime(int a), that returns true if the input a is prime and false otherwise. Write a program that accepts integers for as long as the input is positive and displays for each input of it is prime or not. You do not need to define (don\'t write the body of) is Prime, assume it is in a library, just use it in your main.

Solution

Prime.cpp

#include <iostream>

using namespace std;
int main()
{
int n = 0;
while(n<=0){
cout << \"Enter a number: \";
cin >> n;
}
if(isPrime(n)){
cout<<\"Given number \"<<n<<\" is a prime.\"<<endl;
}
else{
cout<<\"Given number \"<<n<<\" is not a prime.\"<<endl;
}

return 0;
}

 Assume that you are given a function bool isPrime(int a), that returns true if the input a is prime and false otherwise. Write a program that accepts integers

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site