Palindrome program in C

What is Palindrome Number, 

Palindrome number in c language: A palindrome number is a number that is same after reverse. For example: 121, 131, 151, 34543, 343, 48984 are the palindrome numbers.
Palindrome number Program are asked interviewer for freshers and Experience holders.

How to Write a Palindrome number Program & its Execution Steps 

  • Take the number from user Input
  • Hold these number in temporary variable
  • Reverse Input number
  • Compare the temporary number with the reversed number
  • If both numbers are same, print palindrome number
  • Else print not palindrome number
Lets see how to write a Program of palindrome number using in C langusge. In this c program, we will get an input from the user and check whether number is palindrome or not.
  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. main()  
  4. {  
  5. int n,r,sum=0,temp;  
  6. clrscr();  
  7. printf(“enter the number=”);  
  8. scanf(“%d”,&n);  
  9. temp=n;  
  10. while(n>0)  
  11. {  
  12. r=n%10;  
  13. sum=(sum*10)+r;  
  14. n=n/10;  
  15. }  
  16. if(temp==sum)  
  17. printf(“palindrome number “);  
  18. else  
  19. printf(“not palindrome”);  
  20. getch();  
  21. }  
enter the number=151
palindrome number
enter the number=5621
not palindrome number

Leave a Reply

Your email address will not be published. Required fields are marked *