Infolinks - Earn Easy Money

Friday, April 3, 2015

C++ program to calculate either the number is palindrome or not

#include <iostream>
using namespace std ;
int main (  )
{
int n , rev = 0 ;
cout <<" Enter the number ";
cin >> n ;
for ( int n1 = n ; n1 > 0 ; n1 = n1 / 10 )
{
rev = rev * 10 + n1 % 10 ;
}
cout << rev ;
if ( rev == n )
{
cout <<" \n The number is a palindrome ";
}
else
{
cout <<" \n The number is not pelindrome ";
}
return 0 ;
}

No comments:

Post a Comment

Must drop your comments about post.