OK here is what I have now

Code:

#include <stdio.h> /* define fopen,fclose,fscanf,fprintf */
#include <math.h> /* sqrt definition */
#define TRUE 1
#define FALSE 0
int is_prime(int num);
int main(void)
{
FILE *inp,
*outp;
int number;
int input_status;
int finish;
inp = fopen("prime.dat","r");
outp = fopen("prime.out","w");
input_status = fscanf ( inp, "%d", &number);
finish = number;
while (input_status == 1){
if (is_prime(number))
fprintf(outp, " %d is a prime number\n",number);
else
fprintf(outp, " %d is not a prime number\n",number);
input_status = fscanf ( inp, "%d", &number);
}
fclose(inp); /* close files */
fclose(outp);
return(0);
}
int is_prime(int num)
{
int div;
int all_div;
int result;
if (num == 1)
return(FALSE);
else if (num == 2)
return(TRUE);
all_div = sqrt((double)num);
for(div = 2; div <= all_div; div++)
{
if(num % all_div == 0)
result = FALSE;
else
result = TRUE;
}
return(result);
}

For some reason, I am not getting correct calculations.

Here is what I get when I run it.

50 is a prime number

17 is a prime number

45 is a prime number

19 is a prime number

2 is a prime number

36 is not a prime number

31 is a prime number

41 is a prime number

52 is a prime number

80 is not a prime number

84 is a prime number

65 is a prime number

61 is a prime number

63 is not a prime number

77 is a prime number

Can someone please help me with what I'm doing wrong?

Thanks