krazyapril4601
26.09.2019 •
Computers and Technology
Aprime number is a number that is only evenly divisible by itself and 1. for 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. design a boolean function called isprime, that accepts an integer as an argument and returns true if the argument is a prime number, 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: getnumber, that accepts a ref to an integer, prompts the user to enter a number, and accepts that input isprime, that accepts an integer as an argument and returns true if the argument is a prime number, or false otherwise showprime, that accepts an integer as an argument , calls isprime, and displays a message indicating whether the number is prime the main module, that will call getnumber and showprime
Solved
Show answers
More tips
- O Other How to Accidentally Get a Rare Coin with Your Change and How to Know Its Value?...
- S Society and Politics How Could Nobody Know About the Dead Mountaineers?...
- D Dating, Love, Relationships Why do we feel shame?...
- F Family and Home Why Does God Punish Us Constantly and How Can We Fix It?...
- F Family and Home Do Lullabies Help Babies Sleep or Is it Just a Myth?...
- B Business and Finance How to Get Your Money Back When Lending? Top 7 Ways...
- S Society and Politics Выборы: Смысл, Значение и Отражение...
- D Dating, Love, Relationships Why Should the Man be Active and the Woman Passive during Foreplay?...
- P Philosophy How did the concept of module arise in computer science?...
- S Society and Politics Why are thugs called gopniks ? A fascinating journey through Russian subculture...
Answers on questions: Computers and Technology
- S Social Studies Stacy and mindy enjoy organized games, play hours of monopoly, and have become champions at marbles. the girls are engaged in play....
- S Spanish Cómo food Cómo funcionan las células madre en los terapias...
- E English Using text evidence state the tone in the beginning of their phone conversation?...
Ответ:
// here is code in C++.
#include <bits/stdc++.h>
using namespace std;
// function to check prime
bool isPrime(int n)
{
// if input is less than 1
if(n<1)
return false;
// if input is 1,2 or 3
else if (n == 1||n ==2 ||n==3)
{
return true;
}
// if input is greater than 3
else
{
for(int i=2; i<n; i++)
{
if(n%i==0)
return false;
}
return true;
}
}
// driver function
int main()
{
// variable
int num;
cout << "Enter a number: ";
// read the input number
cin >> num;
// call function to check prime
if (isPrime(num)==true)
// if prime
cout << num << " is prime.";
else
// if not prime
cout << num << " is not prime.";
return 0;
}
Explanation:
Read a number from user and assign it to "num".Then call the function isPrime() with "num" as parameter.In this function, if the input is less than 1 then it will return "false".If input is 1 or 2 or 3 then it will return "true".For an input greater than 3, if the number is divisible by only 1 and itself then function will return "true" otherwise it will return "false".
Output:
Enter a number: 17
17 is prime.
Ответ:
I do not know 100% but i think it is the Exit which is letter D
Explanation: