OneCompiler

C++ program to check given number Palindrome or not.

242

Following c++ program checks the given integer or number is Palindrome or not using while loop

#include <iostream>
using namespace std;
int main() {
  int n = 212, r, sum = 0, temp;
  temp = n;
  while (n > 0) {
    r = n % 10;
    sum = (sum * 10) + r;
    n = n / 10;
  }
  if (temp == sum)
    cout << "Number is Palindrome.";
  else
    cout << "Number is not Palindrome.";
  return 0;
}

Output:

Number is Palindrome.

Try it Online here https://onecompiler.com/cpp/3x73s7wh3