1. C Programming for Beginners: Writing Your First Hello World Program in C in 2023 2. Mastering Datatypes in C Programming: A Comprehensive Guide for Beginners in 2023 3. Complete Guide to % Format Specifiers in C for Beginners in 2023 4. A Comprehensive Guide to Operators in C Programming: Learn Everything About Operators in C in 2023 5. Master C Operator Precedence and Associativity in 2023: Definition, Examples, and Code 6. Learn Increment and Decrement Operators in C: A Beginners Guide with Examples - Codzify 7. Mastering Bitwise Operators in C: A Comprehensive Guide with Examples - Codzify 8. Ternary Operators in C Programming: A Beginners Guide (2023) 9. Switch Statements in C 2023: Complete Guide for Beginners 10. Learn Functions in C Programming - A Complete Tutorial for Beginners in 2023 11. Call by Value and Call by Reference in C Programming - A Complete Tutorial for Beginners in 2023 12. Storage Classes in C Programming: A Comprehensive Guide for 2023 13. Arrays in C Programming: A Comprehensive Guide for 2023 14. Basics of 2D Array in C Programming in 2023: Definition, Initialization, and Accessing Elements 15. Beginners Guide to Strings in C Programming with Codes and Examples 16. Strings Functions in C Language - strlen, strcpy,strcmp,strcat functions 17. A Comprehensive Guide to Structures in C Programming in 2023 18. Learn Unions in C Programming with Codes, Examples, and Explanations in 2023 19. Dynamic Memory Allocation in C: Understanding malloc, calloc, realloc, and free Functions 20. Introduction to C Programming 21. Hello world program in C 22. String functions in C - strncat, strcpy, strncpy, strchr, strrchr, strstr functions 23. Program for Fibonacci number in C - Codzify.com 24. What is palindrome number in C? 25. Write a C program to find a factorial of a given number 26. Write a C program to check whether a given number is prime or not 27. Write a C program to check whether a given number is an Armstrong number or not. 28. Write a C Program to transpose a matrix 29. C Programming Tutorial: Understanding Comments and Identifiers with Code Examples 30. Master String Handling Functions in C in 2023 - Codzify Topics

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

Explore Tech Guide:

Codzify Logo

Terms and Conditions    Cookie Policy   Refund Policy   Adsense Disclaimer

Contact: teamcodzify@gmail.com