My son & I have been working on this program for hours....days....forever. Output should be all primes from 1-100, but is printing even numbers instead. First time separating function from main, and trying to do it with boolean and looping has thrown us for a loop - we've generated at least 100+ tries. Any hints or pointers would be very much appreciated!
Code:#include<stdio.h> #include<math.h> #include"simpio.h" #include"genlib.h" #define LowerLimit 2 #define UpperLimit 100 #define TRUE 1 #define FALSE 0 bool isPrime (int num); main() { int num; printf("The prime numbers in the range of 1-100 are:\n\n"); for (num=LowerLimit; num<=UpperLimit; num++) if (isPrime (num) == 1) printf("%d\n",num); } bool isPrime (int num) { int j; for (j=2; j<=sqrt(num); j++) { if (num%j==0) return 1; else return 0 ; } }