Hi
Got 2 errors
the program should let me enter number and check whether its a prime or not
Error 1 error C2668: 'sqrt' : ambiguous call to overloaded function c:\users\hani\test4\test4\code.cpp 15
Error 2 fatal error C1903: unable to recover from previous error(s); stopping compilation c:\users\hani\test4\test4\code.cpp 15
PHP Code:
# include <iostream>
# include <cmath>
using namespace std;
int main () {
int n;
int i;
int is_prime=true;
cout << " enter a number ";
cin >>n;
i = 2;
while ( i <= sqrt(n)) {
if ( n % i ==0)
is_prime = false;
i++;
}
if ( is_prime )
cout << " the number is prime "<<endl;
else
cout << " is not prime number "<<endl;
system ("PAUSE");
return 0;
}




Reply With Quote