write a program to check whether a number is prime or not..

#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,ans;
printf("enter a number\n");
scanf("%d",&num);
for(i=2;i<num;i++)
{
ans=num%i;
if(ans==0)
{
printf("%d is not prime number",num);
goto end; 
}
}
printf("%d is prime number",num);
end:
return 0;
}


Comments

Popular posts from this blog