# Palindrome Program in C | Program to Check the Number is Palindrome or not

Posted in

Vinay Khatri
Last updated on July 22, 2022

Here in this program, we will code to check whether an entered number is a palindrome number or not. let's discuss the Palindrome Program in C.

## Palindrome Program in C

### What is a Palindrome number?

A palindrome number is a special number because it remains the same when its digit gets reversed. For example, 16461 is a palindrome number if you reverse this number still, we get 16461. By default, all the 1-digit numbers are palindrome numbers.

### Statements we will use in this program

• While loop
• % (arithmetic modules)
• If…else statement

### Logic

• First, we will ask the user to enter a number
• Then using a while loop we will try to reverse the entered number using % and other athematic operation
• At last, we will compare the reversed number with the entered number
• If the number match, we will print the number is a palindrome if not we print its not a palindrome number.

### Palindrome Program in C

``````#include<stdio.h>
int main()
{
int num,x, y=0,rev;
printf("Enter a Number: ");
scanf("%d",&num);
rev= num;
while(rev!=0)
{
x= rev%10;
y=x+(y*10);
rev=rev/10;
}

if(num==y)
printf("%d is a palindrome number",num);
else
printf("%d is not a palindrome number",num);
}``````

Output:

```Enter a Number: 14641
14641 is a palindrome number```

#### Conclusion

Checking a palindrome number in C is very easy. The only logic it tasks is reversing the number that we want to check for palindrome. And to reverse a number in C we can use the simple logic where we keep dividing the number by 10 until its quotient becomes 0, which can be achieve with this algorithm ``` while(rev!=0)   {    x= rev%10;    y=x+(y*10);   rev=rev/10;    } ```

People are also reading:

##### Tags:
palindrome number