0

Good day all,

I've been working on this code for a for a while now and I can't seem to find what's wrong.

I am supposed input two numbers and return if this is a twin prime number by just outputting true or false. My program compiles and runs but I am getting false for all my numbers. Twin prime numbers are numbers that are prime and differ by 2

for example, 3 and 5 are prime numbers and differ by 2

Can someone please check my code and tell me what part of it is wrong...

Much appreciated...

```
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
bool isPrime(int a){
for (int i=1; i!=a / 2; i++)
{
int o=0;
if (a % i == 0)
{
++o;
}
if ( o != 1)
return true;
else
return false;
}
}
bool isTwinPrime(int a, int b){
if (isPrime(a) && isPrime(b) && 2 == b - a)
return true;
else
return false;
}
int main()
{
int a, b, isPrime;
cin >> a;
cin >> b;
using namespace std;
cout<< boolalpha<< isTwinPrime (a, b)<<endl;
return 0;
}
```