Checking Palindrome using c++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int x, n, y = 0;
cout << "Enter a number: ";
cin >> x;
n = x;
while (x != 0)
{
int c = x % 10;
y = y * 10 + c;
x = (x / 10);
}
cout << y << endl;
if (n == y)
cout << "The number is Palindrome";
else
cout << "The number is not Palindrome";
return 0;
}
Comments
Post a Comment