1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olya-2409 [2.1K]
3 years ago
14

g Design a Boolean function called isPrime, that accepts an integer as an argument and returns True if the argument is a prime n

umber, or False otherwise. Use the function in a program that prompts the user to enter a number and then displays a message indicating whether the number is prime. The following modules should be written
Computers and Technology
1 answer:
professor190 [17]3 years ago
4 0

Answer:

#include <bits/stdc++.h>

using namespace std;

bool isPrime(int n)

{

   for(int j=2;j<=n-1;j++)  //loop to check prime..

   {

       if(n%j==0)

       return false;

   }

   return true;

}

int main(){

   int n;

   cout<<"Enter the integer"<<endl;//taking input..

   cin>>n;

   if(isPrime(n))//printing the message.

   {

       cout<<"The number you have entered is prime"<<endl;

   }

   else

   {

       cout<<"The number is not prime"<<endl;

   }

return 0;

}

Output:-

Enter the integer

13

The number you have entered is prime

Explanation:

The above written program is in C++.I have created a function called isPrime with an argument n.I have used a for loop to check if the number is prime or not.In the main function I have called the function isPrime for checking the number is prime or not.

You might be interested in
Write your own printArray() function found in Processing for the Arduino. For simplicity, you can limit printArray() to integer
VLD [36.1K]

Answer:

Follows are the method definition to this question:

void printArray(int arrayToPrint[], int arraySize) //defining a method printArray that accepts two array in its parameters

{

for (int j = 0; j < arraySize; j++)//defining for loop print Serial numbers

{

Serial.print("[");//use print method to print square bracket

Serial.print(j);//use print method to print Serial numbers

Serial.print("]: ");//use print method to print square bracket

Serial.println(arrayToPrint[j]);//printing array value

}

}

Explanation:

In the above code, a method "printArray" is declared that holds two arrays "arrayToPrint and arraySize" as a parameter, and inside the method is used for loop to print the values.

In the loop, first, it uses the square bracket to print the serial number and in the last step, it prints array values.

6 0
2 years ago
The most widely used presentation software program is Microsoft PowerPoint. You can produce a professional and memorable present
dolphi86 [110]

Answer:

B

Explanation:

Because you do not want to make your presentation be dark especially in a low lighted room.

(Certified MOS 2016 Powerpoint User)

8 0
3 years ago
When somthing is trustworthy we call it what?
Gnom [1K]

Answer:

dependable

Explanation:

5 0
3 years ago
Read 2 more answers
Karlie wants to eat a good breakfast before taking a test
babymother [125]
Yum sounds like a good idea
7 0
3 years ago
Read 2 more answers
Which part of the website address is its top-level domain name?
mr Goodwill [35]
The top-level domain is usually .com, .org, .net, and many more.
4 0
3 years ago
Other questions:
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • I need help pls, in this code if add row for example :
    8·1 answer
  • A (blank) is a way for students to keep track of information during research
    7·2 answers
  • The two key elements of any computer system are the____and the _____.
    7·1 answer
  • An overall indication of the dependability of data may be obtained by examining the ________, credibility, reputation, and _____
    15·2 answers
  • What can your employer do to protect you from overhead power lines?
    13·1 answer
  • Dave has to create animations for a game. Which tool can Dave use?
    6·1 answer
  • The February Revolution occurred in January.<br><br><br> True<br> False
    5·2 answers
  • What is collaboration
    14·1 answer
  • Question 3 of 10<br> What was the fly in the ointment of Timmy's friendship with Rollo?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!