### help me

I think I may mistake myself. For my homework. Here
 12345678910111213141516171819202122232425262728 #include #include using namespace std; int main() { int n; int i; int is_prime = true; cout << "Enter a number and press Enter: "; cin >> n; i = 2; while (i <= sqrt(n)) { if (n % i == 0) is_prime = false; i++; } if (is_prime) cout << "Number is prime." << endl; else cout << "Number is not prime." << endl; system("pause"); return 0; }

People generally aren't just gonna FIX your code for you...especially if they have no idea what you are asking?

1st - I ran the code just out of curiosity and I see nothing wrong with it...seems to report things correctly.

2nd - I think a proper way to call is_prime would be with "bool" - may want to look up for more clarification (bool = true/false answers vs int which wants to assign numbers).

So what is the problem here?
Number 15 is error. It is said that C:\Users\Duy N. Le\Desktop\C++\prime1.cpp
call of overloaded `sqrt(int&)' is ambiguous
Oh never mine. I found it. http://v2.cplusplus.com/forum/beginner/61858/ =]
Topic archived. No new replies allowed.