C Program to find given number is Prime Number or Not | Program to find Prime Number

C Program to find given number is Prime Number or Not | Program to find Prime Number | Prime Number Assignment in C language




/* wap to find no. is prime or not */
#include
#include

int main()
{
  int num,x=2,p;
  clrscr();
  printf("enter the no");
  scanf("%d",&num);
  while(x<num)
  {
     if(num%x==0)
     {
	p=1;
	break;
     }
     else
     {
       p=0;
     }
     x++;
  }
  if(p==0)
  {
     printf("no.is prime");
  }
  if(p==1)
  {
     printf("no. is not prime");
  }
  getch();
  return 0;
}



No comments:

Post a Comment