A **positive** integer which is only divisible by 1 and itself is known as a **prime number.**

For example, 13 is a prime number because it is only divisible by 1 and 13 but, 15 is not a **prime number** because it is divisible by 1, 3, 5 and 15.

This program takes the value of num (entered by the user) and checks whether the num is a prime number or not.

**Prime Number in C++ -Loops**

```
#include<iostream>
using namespace std;
int main()
{
int n,i,flag=1;
cout<<"Enter any number:";
cin>>n;
for(i=2;i<=n/2;++i)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag)
cout<<"\n"<<n<<" is a Prime number";
else
cout<<"\n"<<n<<" is not a Prime number";
return 0;
}
```

**Output of Program**

Enter any number:5

5 is a Prime number