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
Orlov [11]
4 years ago
13

A prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example, the number 5 is prime be

cause it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided by 1, 2, 3, and 6. Write a Boolean function named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, and false otherwise.

Computers and Technology
2 answers:
Natasha_Volkova [10]4 years ago
3 0

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()

ELEN [110]4 years ago
3 0

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.

You might be interested in
______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
natali 33 [55]
NAS - network attached storage
3 0
4 years ago
1. In Access, a template is which of the following? a. A database to manage contacts b. Where a database is stored c. Two tables
sweet [91]
Where a database is stored
7 0
3 years ago
Write the definition of a function divide that takes four arguments and returns no value . The first two arguments are of type i
Nastasia [14]

Answer:

#include <iostream>

using namespace std;

void divide(int numerator, int denominator, int *quotient, int *remainder)

{

*quotient = (int)(numerator / denominator);

*remainder = numerator % denominator;

}

int main()

{

int num = 42, den = 5, quotient=0, remainder=0;

divide(num, den, &quotient, &remainder);

 

return 0;

}

Explanation:

The exercise is for "Call by pointers". This technique is particularly useful when a variable needs to be changed by a function. In our case, the quotient and the remainder. The '&' is passing by address. Since the function is calling a pointer. We need to pass an address. This way, the function will alter the value at the address.

To sum up, in case we hadn't used pointers here, the quotient and remainder that we set to '0' would have remained zero because the function would've made copies of them, altered the copies and then DELETED the copies. When we pass by pointer, the computer goes inside the memory and changes it at the address. No new copies are made. And the value of the variable is updated.

Thanks! :)

8 0
3 years ago
What is the relationship between CAD and CIM ?
Marat540 [252]
<span> CAM( computerised Aided Manufacture) is when you have workers being helped by computerised tools, CIM (computerised intergated manufacture) is when the whole process is computerised, in manufacture this usually uses robotic arms. These can manufacture 24/7 in needed, they can work very accurately ( they are faster and stronger than a human arm) </span>
5 0
3 years ago
Read 2 more answers
What should you always do to clean off tables
ikadub [295]
Wipe then off then spray them down then wipe off again
7 0
3 years ago
Read 2 more answers
Other questions:
  • A paradigm innovation occurs when:
    6·1 answer
  • Which of the following represents inbound logistics for a bookstore
    13·1 answer
  • A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
    12·1 answer
  • What are two constraints that continuous-media files have that conventional data files generally do not have?
    12·1 answer
  • How do I write code in Java for "A spinner for a game has four possible options: blue, red, yellow, green. The chance of landing
    10·1 answer
  • I'm 11, except my profile says I'm 15.
    15·1 answer
  • Applications require you to provide the following basic elements: social security number, experience, and favorite memories. Tru
    11·1 answer
  • How Can I add a image in an HTML program?​ please tell
    6·1 answer
  • Which of the following actions taken by the Fed will increase the nation’s money supply? (Select all that apply.)
    12·1 answer
  • PLEASE HELP! I accidently looked up a link, and now this same link keeps popping up everywhere, how do I stop this!?!? please he
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!