New Android apps UniqueKey

Saturday 7 March 2015

Find enter number pellendrom or not and find number is prime or not


/*program to find enter number pellendrom or not and find number is prime or not*/

#include<stdio.h>
#include<math.h>

main()
{
  int num,i,j,k,rev=0,n,c=0;

  printf("enter the number\n");
  scanf("%d",&num);
  n=num;
  while(num>0)
  {
   i=num%10;
   rev=rev*10+i;
   num=num/10;
  }
   
  if(rev==n)
  {
   printf("%d is pellendrom number\n\n",n);
  }
  else
  {
  printf("%d is not a pellendrom number\n",n);
  }
  for(j=2;j<=n/2;j++)
  {
    if(n%j==0)
    {
      c=1;
      break;
    }
  }
   if((c==1)||(n==1))
   printf("%d is not a prime number\n\n",n);
   else
   printf("%d is a prime number\n\n",n);
   
   


}

No comments:

Post a Comment