Advertisement

Palindrone program in c++

   In this tutorial i will show you to number is palindrone or not 

https://abuzartec.blogspot.com/2021/04/palindrone-program-in-c.html



palindrone number are those number which is repeat as same  for example 121 , 343 , 34543 are the palindrome number .


palindrome number algorithm 

  1. First we take Input from the user 
  2. Hold the number is temperory variable 
  3. reverse the number 
  4. compared the temperory number with reverse number 
  5. If , both number are same print palindrome number 
  6. Else , Print number is not palindrone .

Let's see the palindrome program in c++ . In this programme we take input from the user and reverse the number then the reverse number is compared at temperory number then print palidorme otherwise print number is not palindrome .

Example 

  1. #include<stdio.h>  
  2. int main()    
  3. {    
  4. int n,r,sum=0,temp;    
  5. printf("enter the number=");    
  6. scanf("%d",&n);    
  7. temp=n;    
  8. while(n>0)    
  9. {    
  10. r=n%10;    
  11. sum=(sum*10)+r;    
  12. n=n/10;    
  13. }    
  14. if(temp==sum)    
  15. printf("palindrome number ");    
  16. else    
  17. printf("not palindrome");   
  18. return 0;  
  19. }   


Output 



Enter the number = 151
Palindrome number


Enter the number = 5621
Not palindrome number


This video is based on the related topic 





This article is contributed by Mohd Abuzar . if  you like code with abuzar and would like to contribute you can also write an article or mail at abuzar.abuzar.mohd325@gmail.com .


Please write comment if you find anything incorrect .


Post a Comment

0 Comments