I am having a bit of trouble creating a function that will determine if a number is a prime number or not. I have attempted various ways to do this, and have read up on the Seive of Eratosthenes. Here is my program to find the 1001st prime number. Tell me if I have a glaring mistake.

Thanks all!Code:#include <math.h> #include <stdlib.h> #include <stdio.h> bool isPrime(int); int main() { int num = 3; int counter = 1; while (counter < 1001) { if(isPrime(num) == true) { counter++; num++; } else num++; } printf("%d is the 1001st prime number", num); system("PAUSE"); return 0; } bool isPrime(int num) { int x; if(num % 2 == 0) return false; for(int x = 3; x < sqrt(num) + 1; x++) { if(num % x == 0) { return false; //when I return false, will this break from the function and just immediately return false? break; //I assume this can break the loop, but how do you also break the for loop if you know its false? } } if(x == num - 1) //it got through the loop without returning false so it must be true return true; }