My intention was to count the sum of prime numbers in a certain range. Its working fine when the range is less than or equal to 8. When I take input 9 it shows output 26 while the answer is 17. My program identifying 9 as a prime and adding with the sum.
{
  for(int i=3; i*i<=n; i+=2)
  {
      if(n%i==0) return false;
  }
  return true;
}`
`int main(){
    int t,sum=0;
    cin >> t;
    for(int k = 0; k < t; k++){
        int n;
        cin >> n;
        if(n>=2) sum=2;`
       ` for(int i=3;i<=n;i+=2)
        {
            ifPrime(i);
            if(ifPrime) sum=sum+i;
        }`
      ` cout<<sum<<endl;
       sum=0;
    }
   return 0;
}
 
    