hi, this is my prime number check program, i've posted it here b4, thanks to ur helpfull replys i managed to get it up and running how ever it gives this warning....C4715: 'isPrime' : not all control paths return a value....i cant figureout where the error is. could someone tell me how to fix that up. thanks.

``````#include <iostream>
#include <math.h>

using namespace std;

#define TRUE 1;
#define FALSE 0;

int number;
void getNumber(int &number);
int isPrime(int number);

int main()
{
int number;
getNumber(number);

if (isPrime(number))
{
cout << "\n" << number << "is a prime number\n";
}
if (isPrime(number)==false)
{
cout << "\n" << number << "is not a prime number\n";

}
return 0;
}

void getNumber(int &number)
{

cout << "Please enter a positive number ";

cin >> number;

if (!cin.good())

{
printf("Invalid number entered\n");

exit(1);

}

}

int isPrime(int number)
{
int count=0,count1;

for(count1=2;count1<number;count1++)

{
if (number%count1==0)
{
return FALSE;

}
{
if (count == 0)
return TRUE;
}
}

}``````

There's no guarantee that it will return anything because your return statements are both inside of if statements. Since you're returning true and false you could also make the function a bool rather than int.

There's no guarantee that it will return anything because your return statements are both inside of if statements. Since you're returning true and false you could also make the function a bool rather than int.

hmm..well it works like this, but i want to know how to take the warning off. and yea i made the int isprime ,,, a bool isprime. thanks. but still i dont know how to fix the warning

>>but still i dont know how to fix the warning
Should be obvious -- put a return value at the end of the function. Once the loop ends the function is supposed to return something, but you forgot that instance. I think you can delete lines 65-68 and just return TRUE outside that loop.

thank you all for your help, it works now :).. its really great to get advice like this for a new programmer. thanks guys

Consider also that warnings often times should really be paid attention to, rather than trying to hide them ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.