The last funtion IsPrimeNumber () is giving me an error that states ..."Local Function definitions are illegal"....can someone please tell me why?
This is because you didn't closed the function definition of
void ConvertTotalSeconds (void) (i.e. you didn't put the closing
} while ending the definition of
void ConvertTotalSeconds (void)
)
Also, even if you did, your function isPrimeNumber() will not work. This is because in your function you used
if (Num % Num == 0) and rather I should tell you that every number divided by itself leaves remainder zero.
So you function will always show each number is prime.
djextreme5 showed you how the definition of the isPrime should be, but there is a error in his program too.
He didn't initialized the variable count and incremented its value.
So the definition should be something like this :
int IsPrimeNumber (int num)
{
for(int i = 2; i <= sqrt(num); i++)
if(num % i == 0)
{ cout<<"Is not a prime";
return 0;}
cout<<"Is a prime";
return1;
}
Moreover, the style
void function_name(void ) is not good. Use
void function_name() instead. The first one is old and outdated and is usually used by C programmers.