Palindrome Number in C
Here, you will get the program code to check the Palindrome number in C programming language.
What is Palindrome?
A number that can be read the same, from forward and backward is called a palindrome number.
for Example:-
121
23532
12321
Algorithm of Palindrome Number
● Input the number
● Copy number in temporary variable
● Reverse the temporary number
● Compare both original number and reverse number
● If both numbers are same, print message as ” Number is Palindrome”
● Else print message as “Number is not Palindrome”
Program Code to Check Palindrome Number in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //Program Code of Palindrome in C #include <stdio.h> #include <string.h> int main() { int num,temp,r,k=0; printf("\nEnter a number: "); scanf("%d",&num); temp=num; while(temp!=0) { r=temp%10; temp=temp/10; k=k*10+r; } if (k==num) printf("\n%d is a palindrome",num); else printf("\n%d is not a palindrome",num); return 0; } |
Output
Check out our other C programming Examples