Prine no. check

#include
using namespace std;
int main(){
int n, i= 2;
cout << "Enter no. : " ;
cin >> n;
if( 0<= n){
if( i <= n - 1 ){
if(n%i != 0){
i = i + 1;
}
else if(n%i == 0){
cout << “Not a prime no.”;
}
}
else if(i == n){
cout << “A Prime no.”;
}
}
else{
cout << “Not a valid no.”;
}
return 0;
}

https://ide.codingblocks.com/s/52421
this is my code , whenever I try to enter a Prine no. it is not diplaying " A Prime no "

Mention Question link

To find whether a no. Entered by user is prime or not??

your logic is not correct.

Try this logic:
int main()
{
int n;
cin>>n;
int i;

if(n==2)
{
cout<<“Prime”;
}
else
{
bool yes=true;

for(i=3;i<=sqrt(n);i=i+2)
{
  if(n%i==0)
  {
    yes=false;
  }
}

if((yes==false)||(n%2==0))
  cout<<"NOT PRIME";
else
  cout<<"PRIME";

}
}

#include
#include
using namespace std;
int main()
{
int n;
cin>>n;
int i;

if(n==2)
{
cout<<“prime”;
}
else
{
bool yes=true;

for(i=3;i<=sqrt(n);i=i+2)
{
if(n%i==0)
{
yes=false;
}
}

if((yes==false)||(n%2==0))
cout<<“NOT PRIME”;
else
cout<<“PRIME”;
}
return 0;
}
/* everything is correct except cmath header file is not added and return 0 at the end of the main function is not added.*/