This code checks whether the entered number is a palindrome or not. A palindrome number is a unique number whose reverse is equal to it. For example, 11, 111, 121, 131… are palindrome numbers.
Palindrome Program in C ++
#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int num, temp,l,m=0;
cout<<"Enter a number: ";
cin>>num;
temp= num;
while(num!=0)
{ l = n%10;
m = l+(m*10);
num =num/10;
}
if(temp==m)
cout<<"It’s a palindrome";
else
cout<<"It’s not a palindrome";
getch();
}
Output:
Enter a Number: 1111
It’s a palindrome
Palindrome Program in Python
num =int(input("Enter a Number: "))
temp= num
m=0
while num!=0:
l= num%10
m=l+(m*10)
num=num//10
if temp== m:
print("It’s a palindrome")
else:
print("It’s not a palindrome")
Output:
Enter a Number: 1111
It’s a palindrome
People are also reading:
- WAP to find the greatest number among the three numbers
- WAP in C to Check Whether the Number is a Prime or not
- How to Find Square Root in Python?
- WAP in C++ & Python to calculate the size of each data types
- Python Program to Check Whether a String is Palindrome or Not
- WAP in C++ & Python to reverse a number
- Perfect Number in C
- WAP in C++ & Python to transpose a Matrix
- C++ and Python Code to Find The Sum of Elements Above and Below The Main Diagonal of a Matrix
- WAP to find the Sum of Series 1/2+4/5+7/8+…
Leave a Comment on this Post