Class assignment (requires use of function). Wrote the code. It compiles, runs and gives me the desired result. However, I get warnings... "parameter names (without types) in function declaration, type mismatch with previous implicit declaration, previous declaration of 'is_prime, is_prime was previously implicitly declared to return 'int".
Code:
#include<stdio.h>
void Is_Prime (num);
int main (void)
{
int num;
printf("Enter a Number to Test if it is Prime: ");
scanf("%d",&num);
is_prime (num);
system("PAUSE");
return 0;
} /* End of Main */
void is_prime (int num)
{
int i;
int p = 0;
for(i=1;i<=num;i++)
{
if (num%i==0)
{
p=p+1;
}
}
if(p==2)
printf("%d is a Prime Number\n", num);
else
printf("%d is NOT a Prime Number\n", num);
I have tried renaming the parameter, but then the program does not work. I reordered the code to put the function first and that eliminated all but one warning, "parameter names (without types) in function declaration".
Guidance or a point in the right direction will be appreciated. Thanks in advance.