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?
Last edited on
Please use code tags:
http://www.cplusplus.com/articles/jEywvCM9/

This is not a UNIX/Linux-specific question, edit your topic (not your post) and move it to the beginner's section.

What do you think happens if n != 1 and i != floor(sqrt(n)) + 1?
Oh....it works now...thank you
Topic archived. No new replies allowed.