What is palindrome number in C?

Article by: Manish Methani

Last Updated: September 27, 2021 at 2:04pm IST
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

Simplified Coding for Beginners.








Download the Codzify
Mobile App


Mobile App Development, Web App Development, Programming Languages, Latest Tech News & lot more.

Codzify Mobile App

A self-paced learning Courses Created by an Engineer
For Engineers.

Premium

The Complete Angular Course

Instructor: Manish Methani

Explore Curriculum
Free

C Programming for Absolute Beginners

Instructor: Manish Methani

Start Watching
Premium

Flutter Mobile App Development Course

Instructor: Manish Methani

Explore Curriculum
Free

Learn HTML, CSS & Bootstrap

Instructor: Manish Methani

Start Watching

Test your skills with these expert-led curated
Mock Tests.

C Programming Test

Test your C Programming skills with this comprehensive mock test on C Programming.

Take Test

Flutter Test

Solve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take Test

GATE(CSE) Operating Systems

Solve most asked GATE Questions in Operating Systems and test your Gate Score.

Take Test

HTML,CSS Test

This is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take Test

(GATE CSE) Data Structures & Algorithms Test

Solve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take Test
include_once 'codzify-footer.php'; ?>