View the step-by-step solution to:

Question

Find the five problems in this program. There are both syntax and logical issues. Do not rewrite it, just fix

it.

#include <iostream>

using namespace std;

bool is_prime(int value)

// This program prints out the first 10 odd primes (3, 5, 7, ...)

int main()

{

   int value = 3;

   int counter;

   while( counter < 10 );

   {

     if ( is_prime(value) )

     {

       cout << counter << " " << value << endl;

       counter++;

     }

     value +=2;

   }

   return 0;

}

bool is_prime(int value)

{

   for(int i = 3; i < value / 2; i+=2);

     if ( value % i == 0 )

       return true;

   return false;

}

Top Answer

Below is the fixed code: #include &lt;iostream&gt; using namespace std ; bool is_prime ( int value ) ; // This program prints... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question