In this tutorial i will show you to number is palindrone or not
palindrone number are those number which is repeat as same for example 121 , 343 , 34543 are the palindrome number .
palindrome number algorithm
- First we take Input from the user
- Hold the number is temperory variable
- reverse the number
- compared the temperory number with reverse number
- If , both number are same print palindrome number
- 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
- #include<stdio.h>
- int main()
- {
- int n,r,sum=0,temp;
- printf("enter the number=");
- scanf("%d",&n);
- temp=n;
- while(n>0)
- {
- r=n%10;
- sum=(sum*10)+r;
- n=n/10;
- }
- if(temp==sum)
- printf("palindrome number ");
- else
- printf("not palindrome");
- return 0;
- }
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 .
0 Comments
Do not Comment and any spam text