+ 1

Program to check whether the given number is palindrome or not

27th Oct 2016, 3:52 PM
Sankalp
4 ответов
+ 4
#include<iostream> using namespace std; int main() { int num,n,r,rev; rev = 0; cout<<"Enter the number: "; cin>>num; n = num; while(n>0) { r = n%10; rev = (rev*10)+r; n = n/10; } if(num==rev) cout<<"Number "<<num<<" is palindrome"; else cout<<"Number "<<num<<" is not palindrome"; }
27th Oct 2016, 6:45 PM
Shad Ahmad Zaidi
Shad Ahmad Zaidi - avatar
+ 3
Try that one
27th Oct 2016, 5:13 PM
PATRICK MWANGI
PATRICK MWANGI - avatar
+ 2
when a number is reversed and it remains the same it is called palindrome number for example 22, 44 #include<iostream> using namespace std; int main() { int palindrome, reverse=0; cout<<"Enter number: "; cin>>palindrome; int num=0,key=palindrome; for(int i=1;palindrome!=0;i++){ num=palindrome%10; palindrome=palindrome/10; reverse=num+(reverse*10); } if(reverse==key){ cout<<key<<" is a Palindrome Number"; } else{ cout<<key<<"is NOT a Palindrome Number"; } return 0;
27th Oct 2016, 5:13 PM
PATRICK MWANGI
PATRICK MWANGI - avatar
+ 1
but try a number which is greater than 10 digits .. it FAILS.😔
5th Feb 2017, 1:56 PM
Murtaza Piar
Murtaza Piar - avatar