Ask Question
16 March, 11:56

Use the isprime function that you wrote in programming challenge 21 in a program that reads in an integer that is less than 3001 stores a list of all the prime numbers from 2 through that number in a file name d "primelist. txt". prompts and output labels. no prompts, no labels. after closing the file, the program writes "prime numbers written to primelist. txt." on a line by itself in standard output. input validation if the value read in exceeds 3000, the program silently terminates. / / function prototype bool isprime (int);

+4
Answers (1)
  1. 16 March, 12:58
    0
    Just include all the following data accurately.

    #include

    #include

    using namespace std;

    bool isPrime (int);

    int main ()

    {

    int num=0;

    int i;

    bool prime;

    ofstream outFile;

    outFile. open ("PrimeList. txt");

    while (num = = 0)

    {

    cin >> num;

    }

    for (i=2; i
    if (isPrime (i))

    outFile << i << "/n";

    cout << "Prime numbers written to PrimeList. txt.

    /n";

    outFile. close ();

    return 0;

    }

    bool isPrime (int n)

    {

    int i;

    for (i=2; i
    if (n%i==0)

    return false;

    return true;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Use the isprime function that you wrote in programming challenge 21 in a program that reads in an integer that is less than 3001 stores a ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers