PrimeChecker.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
//File: PrimeChecker.cpp
#include <iostream>
#include <cmath>
using namespace std;
bool PrimeChecker (int n)
{
int i = 2;
if (n != 1)
{
for (; i <= sqrt(n) ; i++)
{
if (n%i == 0)
{
return (false);
i = sqrt(n) +1;
}
}
if (i == floor(sqrt(n)) + 1)
return (true);
}
else
return (false);
}
int main ()
{
int m = 0;
int count = 0;
while(count < 100){
if(PrimeChecker (m)){
cout << m << "\n";
count++;
}
m++;
}
return (0);
}
| |
How do I get rid of the warning? Help please.
Last edited on
Get rid of the else on line 22?
Topic archived. No new replies allowed.