Program to Check Palindrome Number in C Last Updated : 21 May, 2025 Comments Improve Suggest changes Like Article Like Report Palindrome numbers are those numbers that remain the same even after reversing the order of their digits. In this article, we will learn how to check whether the given number is a palindrome number using C program.ExamplesInput: 121Output: YesExplanation: The number 121 remains the same when its digits are reversed.Input: 123Output: NoExplanation: The number 123 does not remain the same when its digits are reversed.In C, we can check if a given number is palindrome or not by using two different methods given below:By Reversing and ComparingA simple method for this problem is to first reverse all the digits of a given number and then compare the reverse of the number with a given number. If both are the same, then the number is a palindrome. C #include <stdio.h> int reverseNum(int N) { // Function to store the reversed number int rev = 0; while (N > 0) { // Extract the last digit int dig = N % 10; // Append the digit to the reversed number rev = rev * 10 + dig; // Remove the last digit N /= 10; } return rev; } int isPalindrome(int N) { // Negative numbers are not palindromes if (N < 0) return 0; return N == reverseNum(N); } int main() { int N = 121; if (isPalindrome(N)) { printf("Yes\n"); } else { printf("No\n"); } return 0; } OutputYes Using Two Pointers and String ConversionIn this method we first need to convert the number into a string and then use the two pointers technique where the first pointer is pointing at the start of the string and the other at the end of the string. Now, we compare the characters they point to while moving these pointers towards each other. If all the characters match by the time pointers meets, the number is a palindrome, otherwise it is not. C #include <stdio.h> #include <string.h> int isPalindrome(int n) { char str[20]; // Convert the number to a string sprintf(str, "%d", n); // Left pointer starting from the first character int left = 0; // Right pointer starting from the last character int right = strlen(str) - 1; // Loop until the pointers meet in the middle while (left < right) { // If mismatch is found (not a palindrome) if (str[left] != str[right]) { return 0; } // Move pointers towards each other left++; right--; } return 1; } int main() { int num = 1221; // Check if the number is a palindrome and print the result if (isPalindrome(num)) { printf("Yes\n"); } else { printf("No\n"); } return 0; } OutputYes Comment More infoAdvertise with us Next Article C Program to Check for Palindrome String mukulsomukesh Follow Improve Article Tags : C Programs C Language C Basic Programs Similar Reads Palindrome String Coding Problems A string is called a palindrome if the reverse of the string is the same as the original one.Example: âmadamâ, âracecarâ, â12321â.Palindrome StringProperties of a Palindrome String:A palindrome string has some properties which are mentioned below:A palindrome string has a symmetric structure which m 2 min read Palindrome String Given a string s, the task is to check if it is palindrome or not.Example:Input: s = "abba"Output: 1Explanation: s is a palindromeInput: s = "abc" Output: 0Explanation: s is not a palindromeUsing Two-Pointers - O(n) time and O(1) spaceThe idea is to keep two pointers, one at the beginning (left) and 13 min read Check Palindrome by Different LanguageProgram to Check Palindrome Number in CPalindrome numbers are those numbers that remain the same even after reversing the order of their digits. In this article, we will learn how to check whether the given number is a palindrome number using C program.ExamplesInput: 121Output: YesExplanation: The number 121 remains the same when its dig 3 min read C Program to Check for Palindrome StringA string is said to be palindrome if the reverse of the string is the same as the string. In this article, we will learn how to check whether the given string is palindrome or not using C program.The simplest method to check for palindrome string is to reverse the given string and store it in a temp 4 min read C++ Program to Check if a Given String is Palindrome or NotA string is said to be palindrome if the reverse of the string is the same as the original string. In this article, we will check whether the given string is palindrome or not in C++.ExamplesInput: str = "ABCDCBA"Output: "ABCDCBA" is palindromeExplanation: Reverse of the string str is "ABCDCBA". So, 4 min read Java Program to Check Whether a String is a PalindromeA string in Java can be called a palindrome if we read it from forward or backward, it appears the same or in other words, we can say if we reverse a string and it is identical to the original string for example we have a string s = "jahaj " and when we reverse it s = "jahaj"(reversed) so they look 8 min read Easy Problems on PalindromeSentence Palindrome Given a sentence s, the task is to check if it is a palindrome sentence or not. A palindrome sentence is a sequence of characters, such as a word, phrase, or series of symbols, that reads the same backward as forward after converting all uppercase letters to lowercase and removing all non-alphanumer 9 min read Check if actual binary representation of a number is palindrome Given a non-negative integer n. The problem is to check if binary representation of n is palindrome or not. Note that the actual binary representation of the number is being considered for palindrome checking, no leading 0âs are being considered. Examples : Input : 9 Output : Yes (9)10 = (1001)2 Inp 6 min read Print longest palindrome word in a sentence Given a string str, the task is to print longest palindrome word present in the string str.Examples: Input : Madam Arora teaches Malayalam Output: Malayalam Explanation: The string contains three palindrome words (i.e., Madam, Arora, Malayalam) but the length of Malayalam is greater than the other t 14 min read Count palindrome words in a sentence Given a string str and the task is to count palindrome words present in the string str. Examples: Input : Madam Arora teaches malayalam Output : 3 The string contains three palindrome words (i.e., Madam, Arora, malayalam) so the count is three. Input : Nitin speaks malayalam Output : 2 The string co 5 min read Check if characters of a given string can be rearranged to form a palindrome Given a string, Check if the characters of the given string can be rearranged to form a palindrome. For example characters of "geeksogeeks" can be rearranged to form a palindrome "geeksoskeeg", but characters of "geeksforgeeks" cannot be rearranged to form a palindrome. Recommended PracticeAnagram P 14 min read Lexicographically first palindromic string Rearrange the characters of the given string to form a lexicographically first palindromic string. If no such string exists display message "no palindromic string". Examples: Input : malayalam Output : aalmymlaa Input : apple Output : no palindromic string Simple Approach: 1. Sort the string charact 13 min read Like