Codzify Web Stories

What is palindrome number in C?

1 min 33 sec

In this article, we are going to cover the following points

  1. What is Palindrome number in C?
  2. Algorithm of Palindrome number
  3. Implementation of Palindrome Program

Palindrome numbers are referred to as those numbers which give the same number after reversing that number.

For example: Suppose a given number is 1551, then the palindrome number of the given number will be 1551.

2) Palindrome number of 343 will be 343.

Algorithm for Palindrome number in C

Lets write the basic algorithm to check whether the given number is palindrome or not.

  1. Get the number as input from the user.
  2. Hold the given number in a new temporary variable.
  3. Reverse the given number.
  4. Compare the temporary number with a reversed number.
  5. If both the temporary number and reverse numbers are the same, then the given number will be palindrome else number is not a palindrome.

Implementation of Algorithm

Write a program to reverse a number and check whether a given number is palindrome or not.

#include
 int main() 
 {
int i=1551,j;
j = i;
int n,rem,quo,newnumber=0;
for(n=1;n<=4;n++)
{

rem=i%10;

if(n == 4)
{                    
newnumber=(newnumber+rem);
}
else
{
newnumber=(newnumber+rem)*10;
}
quo=i/10;
i=quo;


}

printf("
New number = %d",newnumber);
printf("
Old number = %d",j);


if(j == newnumber)
{
   printf("
Palindrome");
}
else
{
   printf("
Not Palindrome");

}
}

Output

New number = 1551
Old number = 1551
Palindrome

Previous Next



NEWSLETTER

Coding Bytes by Codzify

Welcome to Coding Bytes, your weekly source for the latest coding tutorials and insights in small byte sized content.

Join 798+ Subscribers

Subscribe on LinkedIn


Monetize your Passion Today!

Join Codzify Affiliate Program, Earn 30% Commission on Course Sales, Get ₹449.7 or $5.41 per course Sale! No Follower Requirement. Monetize Your Passion Today!

Register NOW!

Codzify Youtube Channel

Ready to level up your Full Stack App development Skills? Check out Codzify Youtube Channel for interatcive video content.

Subscribe Codzify







Curated Mock Tests

Prepare for your next Interview or Competitive Exam with our expert-led curated Mock tests in GATE(CSE) DSA, Flutter, HTML, C etc.

Explore Mock Tests

Codzify Web Stories

Codzify Logo

Explore Coding in Simplified Way with Codzify.com


Terms and Conditions    Cookie Policy   Refund Policy