C Program to Check Whether a Number is Prime Number or Not using c function
Answers
Answered by
0
#include <stdio.h>
#include <conio.h>
void main()
{
int num,res=0;
clrscr();
printf("\nENTER A NUMBER: ");
scanf("%d",&num);
res=prime(num);
if(res==0)
printf("\n%d IS A 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;
}
Similar questions