WAP to check whether a given number is prime or not


void main()
{
int no,i;
clrscr();
printf("Enter the no");
scanf("%d",&no);
for(i=2; i<=no; i++)
{
if(no%i==0)
break;
}
if(no==i)
{
printf("prime");
}
else
{
printf("not prime");
}
getch();
}

No comments:

Post a Comment