C program to check whether a number is prime or not using function

C program to check whether a number is prime or not using function

Write a C program to check whether a number is prime or not using the function.


#include 
int main()
{
int num,res=0;
printf("ENTER A NUMBER:\n");
scanf("%d",&num);
res=prime(num);
if(res==0)
printf("\n%d is PRIME NUMBER",num);
else
printf("\n%d is not a PRIME NUMBER",num);
getch();
}
int prime(int n)
{
int i;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
else
return 1;
}
return 0;
}