Write a C program to enter any number and check whether given number is palindrome or not using for loop. How to check whether a number is palindrome or not in C programming. C program for palindrome numbers.

Input number: 121

Output: 121 is Palindrome

For example: 121

Reverse of 121 is also equal to 121. Hence 121 is a palindrome number.

Happy coding ;)

**Example:**Input number: 121

Output: 121 is Palindrome

### Required knowledge

Basic C programming, If else, For loop#### Palindrome numbers

Palindrome numbers are such number which when reversed are equal to the original number.For example: 121

Reverse of 121 is also equal to 121. Hence 121 is a palindrome number.

### Logic to check palindrome numbers

From the definition of the palindrome numbers it must be clear to all that in-order to check whether a number is palindrome or not we must find the reverse of the number. After retrieving the reverse of number we just need to make a conditional check that whether the given number is equal to its reverse or not. If the given number and its reverse are same then the number is palindrome otherwise not.### Program to check palindrome number

/** * C program to check whether a number is palindrome or not */ #include <stdio.h> int main() { int n, num, rev = 0; /* Reads a number from user */ printf("Enter any number to check palindrome: "); scanf("%d", &n); num = n; //Copies original value to num. /* Finds reverse of n and stores in rev */ while(n!=0) { rev = (rev * 10) + (n % 10); n = n/10; } /* Check if reverse is equal to original num or not */ if(rev==num) { printf("%d is palindrome.", num); } else { printf("%d is not palindrome.", num); } return 0; }

**Note:**After learning this also advance your skills by learning this using recursive function. Learn how to check palindrome numbers using recursion.

Output

Enter any number to check palindrome: 121

121 is palindrome.

121 is palindrome.

Happy coding ;)

### You may also like

- Loop programming exercises index.
- C program to find sum of first and last digit of a number.
- C program to calculate product of digits of a number.
- C program to print all factors of a given number.
- C program to print factorial of any number.
- C program to print table of any number.
- C program to print all natural numbers between 1 to n.
- C program to print the sum of all odd numbers between 1 to n.
- C program to print the sum of all even numbers between 1 to n.
- C program to check whether a number is prime number or not.
- C program to and check whether a number is perfect number or not.
- C program to check whether a number is armstrong number or not.
- C program to check whether a number is strong number or not.

< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).