Check Adam

Description:

If a number when reversed , the square of the number and the square of the reversed number should be numbers which are reverse of each other For Example: 12^2 = 144 21^2 = 441 144 is the palindrome of 441 441 is the palindrome of 441 So, 12 is an Adam number. Test Case 1 Input (stdin) 12 Expected Output Adam Number Test Case 2 Input (stdin) 15 Expected Output Not an Adam Number

Program :

#include <bits/stdc++.h>

using namespace std;

int reverseDigits(int num)

{

    int rev = 0;

    while (num > 0)

    {

        rev = rev * 10 + num % 10;

        num /= 10;

    }

    return rev;

}

 

int square(int num)

{

    return (num * num);

}

 

bool checkAdamNumber(int num)

{

    int a = square(num);

    int b = square(reverseDigits(num));

    if (a == reverseDigits(b))

    return true;

    return false;        

}

 

int main()

{

    int num;

      cin>>num;

    if (checkAdamNumber(num))

    cout << "Adam Number";

    else

    cout << "Not an Adam Number";    

     

    return 0;

}