Palindrome or not using C

Write a C program to find number is Palindrome or not

A palindrome number is a number that is given the same number after reverse. In C programs to check if the input number is palindrome or not. We are using while loop and else if statement in C Program.

Ex:-

  • A number is 123321 .If you read number “123321” from reverse order, it is same as “123321”. 

    In that  number is a palindrome. 

  • 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 programming(1)

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.

C Program:-

#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("it is not a Palindrome number");
return 0;
}

Output:-

Enter the number 

121121

Number 121121 is Palindrome number.

Please Login/Signup to comment