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;}
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;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here