Is_prime function How to make 3 cout is prime?

How to get my code to cout 3 as a prime number. When any and ever other number works correctly except #3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  #include <iostream>
using namespace std;
bool is_prime(int n)
{
      for (int i=2; i<=n/2; i++)
    {


    if (n%i==0 || n%3==0)
    {
        return 0;//False
    }


        else if (n=3)
        {
            return 1;//True
        }
    }



}




int main( )
{
    int n;
    bool result;
cout<< "Enter a number ";
cin>> n;
if (is_prime(n)==true)
{
    cout<<n<<" is a prime number"<<endl;
}
else
{
    cout<<n<<" is not a prime number"<<endl;
}


}
-W{all,extra,pedantic}
foo.cpp:15:13: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
                else if (n=3)
                         ~^~
foo.cpp:15:13: note: use '==' to turn this assignment into an equality comparison
                else if (n=3)
                          ^
                          ==
foo.cpp: In function ‘bool is_prime(int)’:
foo.cpp:23:1: warning: control may reach end of non-void function [-Wreturn-type]
Topic archived. No new replies allowed.