Apparently, the for loop is executed everytime which changes the value of bool to false, and always show that the given number is composite
#include <iostream>
using namespace std;
int main()
{
int a, b;
bool Prime=true;
cout << "Enter the number to check for Prime Number: ";
cin >> b;
if (b == 0, 1)
{
Prime=false;
}
else
{
for (a = 2; a < b; a++)
{
if (b % a == 0)
{
Prime=false;
break;
}
}
}
if (Prime)
{
cout << "The given number is a Prime Number";
}
else
{
cout << "The given number is not Prime, i.e. it is composite";
}
return 0;
}