#include<iostream>#include<cmath>usingnamespacestd;intmain(){doublen;// Declaring variable i and n boolis_prime=true;// Boolean flag; assume true until proven otherwisecout<<"Enter a number and press ENTER: ";cin>>n;for(inti=2;i<=sqrt(n)&&n%i==0;i++)// Test for prime by checking for divisibility by all whole numbers from 2 to sqrt(n).{boolis_prime=false;}if(is_prime=true){cout<<"Number is prime."<<endl;}else{cout<<"Number is not prime."<<endl;}system("PAUSE");return0;}
Only to have line 12
for (int i = 2; i <= sqrt(n) && n%i == 0; i++)
have an error message of : invalid operants of type 'double' and
Please help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to compile this program:
Only to have line 12
have an error message of : invalid operants of type 'double' and
Please help!