Skip to content
Home » C Programs » C Program to Check Adam Number or Not

C Program to Check Adam Number or Not

Simple adam number in c for beginners. In this program we can check the number is adam number or not in c program for beginners.

Adam Number Definition

When an Adam number is reversed, the square of the number and the square of the reversed number should be integers that are opposite each other.

While Loop Definition

The while statement allows you to loop over a statement until a defined expression is false. When we don’t know how many times it will repeat, we utilise the while loop. If that number is infinite, or the loop’s Boolean condition is never set to False, the loop will run indefinitely.

If Else Definition

In C, the if-else statement is used to perform operations based on a given circumstance. If and only if the supplied condition is true, the operations described in the if block are carried out.

Adam Number in C

//adam number in c
#include<stdio.h>
#include<math.h>
void main()
{
int r,p,m,b,n,rev,a,c,i,z;
r=0;
rev=0;
printf("Enter any number between 10 and 100:");
scanf("%d",&z);
n=z;
c=n*n;
while(n!=0)
{
m=n%10;
r=r*10+m;
n=n/10;
}
printf("\nThe square of %d is %d",z,c);
printf("\nThe reverse of %d is %d",z,r);
p=r*r;
printf("\nThe square of %d is %d",r,p);
while(c!=0)
{
a=c%10;
rev=rev*10+a;
c=c/10;
}
if(rev==p)
printf("\n%d is an Adam Number",z);
else
printf("\n%d is not an Adam Number",z);
}

Output of adam number in c:

Enter any number between 10 and 100:
The square of 50164544 is 6459392
The reverse of 50164544 is 44546105
The square of 44546105 is -1024459599
50164544 is not an Adam Number