Adam Number

Adam Number is a number whose square of the number and square of it’s reverse are reverse to each other.

Example 1: 12. Here 122 = 144 and 212 = 441. We observe that the square of 12 and the square of it’s reverse i.e. 21 are reverse of each other. Thus 12 is an Adam Number.

Example 2: 13. Here 142 = 196 and 412 = 1681. Here the square of 14 and the square of it’s reverse i.e. 41 are not reverse of each other. Thus 14 is not an Adam Number.

C
#include <stdio.h>
void main()
{
    int n=0,r=0,rev=0,nCopy=0;
    printf("Enter a Number: ");
    scanf("%d",&n);
    nCopy=n;
    while(n>0)
    {
        r=n%10;
        rev=(rev*10)+r;
        n=n/10;
    }
    n=nCopy;
    nCopy=rev*rev;
    rev=0;
    while(nCopy>0)
    {
        r=nCopy%10;
        rev=(rev*10)+r;
        nCopy=nCopy/10;
    }
    if(rev==(n*n))
    {
        printf("%d is an Adam number",n);
    }
    else
    {
        printf("%d is not an Adam Number",n);
    }
}
C