Finding prime numbers results in all odd numbers
<p>I wrote a program, which takes 10 integers from user, and then counts the prime numbers in it and displays the sum. The problem is that it is taking all odd numbers as prime numbers. I have tried very long but couldn't figure it out. Here is the program.</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;conio&gt;
#include&lt;math&gt;

int isPrime(int);

int main()
{
    int sum_of_prime;
    int count=0;
    int a[10];
    for(int i=1; i&lt;=10; i++){
        cout&lt;&lt;"Enter a number: ";
        cin&gt;&gt;a[i];
        if( isPrime(a[i]) ){
            sum_of_prime+=a[i];
            countp++;
        }
    }
    cout&lt;&lt;"Total Prime Numbers in given Numbers: "&lt;&lt;count&lt;&lt;endl;
    cout&lt;&lt;"Sum of All the prime numbers in given numbers"&lt;&lt;sum_of_prime&lt;&lt;endl;
    getch();
}

int isPrime(int n){
    for(int i=2; i&lt;=sqrt(n); i++){
        if(n%i==0)
            return 0;
        else
            return 1;
    }
}
</code></pre>
