Palindrome or not using C

C program to find number is Palindrome or not

A palindrome number is a number that is given the same number after reverse. We are using while loop and else if statement in C Program.

Example:-

  • A number is 123321 .If you read number “123321” from reverse order, it is same as “123321”. 
  • A number is 12121. If we read number “12121” from reverse order ,it is same as 12121. It is also a palindrome number 
palindrome or not in c

Working:-

Step 1.Take the number which you have to reverse and find palindrome as the input variable says number.

Step 2.Number is stores in his duplicity value as a duplicate variable (n1).

Step 3.Obtain its quotient and remainder.

Step 4.Multiply the separate variable with 10 and add the obtained remainder to it.

Step 5.Do step 2 again for the quotient and step 3 for the remainder obtained in step 4.

Step 6.Then we check if reverse is equal to a number.

Step 7.Its true display number is palindrome

Step 8.It is false display number is not a palindrome.

Step 9.stop.

Palindrome Number

C Code

#include<stdio.h>
int main()
{
   //Initialization of variables where rev='reverse=0'
   int number, rev = 0,store, n1,left;

  //input a numbers for user
  printf("Enter the number\n");
  scanf("%d", &number);

  //for duplicacy of number
  n1=number;

  store= number;
  //use this loop for check true condition
  while (number > 0)
  {
    //left is for remider are left
    left= number%10;

    //for reverse of no.
    rev = rev * 10 + left;

    //number /= 10;
    number=number/10;
  }
  //To check reverse no is a Palindrome 
  if(n1==rev)
      printf("Number %d is Palindrome number",n1);
  else
      printf("Number %d is not a Palindrome number",n1);
  return 0;
}

Output:-

Enter the number
234
Number 234 is not a Palindrome number