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
timurjin [86]
3 years ago
11

6.21: isPrime Function A prime number is an integer that is greater than 1 and that is only evenly divisible by itself and 1. Fo

r example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete program that prompts for a number and indicates whether or not it is prime.
Computers and Technology
1 answer:
elena-s [515]3 years ago
5 0

Answer:

The program to this question can be given as:

program:

#include <iostream> //define header file.

using namespace std;

int isPrime (int number);    //declare function.

int isPrime(int number)       //function definitation.

{

int i;

if(number<1)             //conditional statements.

return false;

else if (number == 1||number ==2 ||number==3)

{

return true;

}

else

{

for(i=2; i<number; i++)

{

if(number%i==0)

return false;

}

return true;            

}

}

int main ()            //main method.

{

int number=0;            //declare variable.

cout << "Enter a number for check it is prime number or not : ";   //print message.

cin >> number;     //input by user.

if (isPrime(number)==true)         //check condition.

cout << number << " is prime.";          

else

cout << number << " is NOT prime.";

return 0;

}

Output:

Enter a number for check it is prime number or not : 3

3 is prime.

Explanation:

In this program we  define a function that is (isPrime()).In this function, we pass the user input as a parameter. Then we use conditional statement in these statements we check the number is divisible by itself and 1.If the number is divisible it returns true otherwise it returns false. In the last we define the main function in that function we take user input and pass it in the function, and print its return value.

You might be interested in
Which three of the following are used for mobile Internet access?
AlladinOne [14]
Bluetooth wifi and cell tower
8 0
4 years ago
Read 2 more answers
What are the limits of hashing and verifying that files haven’t changed?
earnstyle [38]

The hashing function can take any number of key-value pairs and there is no specific limit to it.

<h3>What is hashing?</h3>

Hashing is a file-based algorithm for producing a fixed-length bit string value. A file is essentially a collection of data blocks. The length of the data is reduced by hashing to a fixed number or key that represents the original string.

When hashing is employed, the hash function may plot all of the keys and values to what the real size of the table is, demonstrating that the hashing function can take any number of key-value pairs with no restriction.

However, if the passwords are hashed in encryption, recovering the passwords is extremely difficult.

Thus, the hashing function can take any number of key-value pairs and there is no specific limit to it.

Learn more about the hashing here:

brainly.com/question/13106914

#SPJ1

5 0
2 years ago
What does the following code do? Assume list is an array of int values, temp is some previously initialized int value, and c is
BigorU [14]

Answer:

Option D is correct.

Explanation:

Option D is correct because  when the condition  if (list[j] < temp) is tested it only gets true when element in list[] array at <em>jth</em> position is less than the value in <em>temp</em> and after that it increments the value of c by this statement: c++ and so c is incremented from 0 to as much times as much elements in list[] are lesser than temp.

6 0
4 years ago
Read 2 more answers
Tyrell is required to find current information on the effects of global warming. Which website could he potentially cite as a cr
Katarina [22]

Answer:

2345

Explanation:

5 0
3 years ago
Read 2 more answers
How old am i <br> (Will give brainliest)
diamong [38]
You’re probably thirteen
4 0
3 years ago
Other questions:
  • For wired network cards that get their IP addresses through DHCP, what can be set manually?
    5·1 answer
  • Robert needs to apply formatting from one set of text to multiple other sets of text throughout the document. Which option shoul
    7·1 answer
  • A tornado may be approaching if you observe which of the following?
    15·1 answer
  • Which are considered regulatory agencies? Check all that apply. WHO PPO HMO CMS CDC NIOSH
    11·2 answers
  • C++
    11·2 answers
  • Who do you guys ship lol bit with?
    14·2 answers
  • In order to preview an attachment in an e-mail, click the attachment in the ______
    8·1 answer
  • Lucas wants to expand his vocabulary to better understand the sentence below. The insidious burglar moved through the house unhe
    7·2 answers
  • Briefly explain the emerging trends in micro computer technology in relation to size
    10·1 answer
  • What is the difference between referential and entity integrity
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!