15. In this c++ program. Create a flowchart and algorithm. Source Code: #include using namespace std; int main() { int i, n; bool is_prime = true; cout > n; // 0 and 1 are not prime numbers if (n ==...


15. In this c++ program. Create a flowchart and algorithm.


Source Code:


#include
using namespace std;


int main() {


  int i, n;
  bool is_prime = true;


  cout < "enter="" a="" positive="" integer:="">
  cin >> n;


  // 0 and 1 are not prime numbers
  if (n == 0 || n == 1) {
    is_prime = false;
  }


  // loop to check if n is prime
  for (i = 2; i <= n/2;="" ++i)="">
    if (n % i == 0) {
      is_prime = false;
      break;
    }
  }


  if (is_prime)
    cout < n="">< "="" is="" a="" prime="">
  else
    cout < n="">< "="" is="" not="" a="" prime="">


  return 0;
}



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here