C Program For Palindrome – Check Whether A Number Is Palindrome Or Not

C Program For Palindrome – What is Palindrome? A palindrome is a sequence of characters which reads the same backward as forward. A palindrome could be a word, phrase, number, or other sequences of characters. such as madam or racecar.

Palindrome Number Examples:

1001, 2552, 32423, 959, Etc.

Palindrome Word Examples:

Madam, Racecar, Etc.

C Program For Palindrome

If you are looking for a palindrome in C program, this article will help you to learn how to write palindrome program in C language. Just go through this C program for palindrome to check whether a number is palindrome or not. After going through this C programming tutorial, you will be able to write a  C palindrome program.

C Programming Tutorials

C Program For Palindrome String

C Program To Reverse a String with Using Function

C Program To Reverse a String without Using Function

C Program To Reverse a String Using Recursion

C Program To Reverse a String Using Pointers

C Program For Palindrome Numbers

Learn how to write a  Palindrome program in C language. Writing a C program to check whether a number is a palindrome or not can be done using various techniques, but here in this program, we show how to write palindrome program in a proper way.

This is the seventh C programming example in the series, it helps newbies, students and B.Tech graduates in enhancing C programming and land on their dream job. All the best guys in learning c programming with coding compiler website. Happy Learning.

C Program For Palindrome Source Code

Copy paste the below source code or write your own logic into C compilers and run the program to see the result.

/* C PROGRAM FOR PALINDROME - PALINDROME.C */

#include <stdio.h>
int main()
{

//Variables declaration

 int n, reversedInteger = 0, remainder, originalInteger;

//Taking input number from user

printf("Enter a number: ");
 scanf("%d", &n);

originalInteger = n;

// reversed integer is stored in "reversedInteger" variable
 
 while( n!=0 )
 {
 remainder = n%10;
 reversedInteger = reversedInteger*10 + remainder;
 n /= 10;
 }

// palindrome logic
// if orignalInteger and reversedInteger are equal
// then it is a palindrome

 if (originalInteger == reversedInteger)
 printf(" Entered Number %d is a Palindrome.", originalInteger);
 else
 printf(" Entered Number %d is Not a Palindrome.", originalInteger);
 
 return 0;
}

C PROGRAM For Palindrome OUTPUT

After you compile and run the above program, your C compiler asks you to enter a number to check whether a number is palindrome or not. After you enter a number, the programming logic will check and show result like below expected output.

Enter a number:

1001

Entered Number 1001 is a Palindrome.

 

Read Other C Programming Tutorials:

C Program To Swap Two Numbers Using Two Variables

C Program To Swap Two Numbers Using Three Variables

C Program For Prime Numbers – Check  a Number is Prime or Not

C Program To Reverse a String with Using Function

C Program to Reverse a String without Using Function

C Program to Reverse a Sting Using Recursion

Leave a Comment