Respuesta :
Answer:
Since no programming language is stated, python will by used.
Explanation:
def isPrime():
#first we ask for a number that will be tested
data= int(input("please enter a number"))
#the next line is where the number will be tested to see if its a prime
if (data>1):
if(data % 2)==1:
print("true")
else:
print("False")
else:
print("Enter a number greater than 1")
isPrime()
Answer:
I am writing a C++ program.
bool isPrime(int integer) //boolean function that takes integer argument //and returns true if argument is prime number otherwise false
{ if (integer > 1) // if the integer value is greater than 1
{ for (int i = 2; i <= integer; ++i)
//loop starts from 2 and iterates until the value of i gets greater than integer //value
{ if (integer % i == 0) // if integer value is completely divisible by i
{ if(integer == i) // if integer value is equal to i
return true; //function returns true
else //if integer value is not divisible by i
return false; //function returns false } } } } }
Explanation:
In order to see the output of the program you can write a main() function as following:
int main() { //start of the main() function body
int integer; // int type variable integer
cout<< "Enter an integer: "; //prompts user to enter an integer value
cin >> integer; //reads the input from user
cout << integer<<" "; //prints the integer value entered by user
if (isPrime(integer))
// calls boolean function to check if the integer value is prime number or not
{ cout << " is a Prime number." << endl; }
//displays the message number is prime
else //if the integer value is not prime
cout << " is not a Prime number." << endl; } //displays message
The output along with the program is attached as screenshot.

