Is it correct and/or is there a better/simpler/faster way of doing the same thing?

#include <time.h> #include <math.h> int main() { unsigned long n, i=3, count=0, c, abcd = 3; long double launch, done, diff; launch = clock(); // Only checking from 2 to square root of number is sufficient for (abcd=3; abcd < 100000; abcd++) { for ( c = 2; c <= (int)sqrt(abcd); c++ ) { if (abcd%c == 0) // Divisable so not a prime number { break; } else { if(c==(int)sqrt(abcd)) { printf("%ld\n",abcd); count++; } } } } done = clock(); diff = (done - launch) / CLOCKS_PER_SEC; printf("Number of Prime Numbers : %d\n",count); printf("Total time taken by CPU %Lf Clocks - %Lf Clocks = %Lf seconds with CLOCKS_PER_SEC @ %d\n",done, launch, diff, CLOCKS_PER_SEC ); return 0; }