This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Wednesday 5 June 2013

Program to check whether the given number is Adam Number or not


#include<stdio.h>
#include<math.h>
void main()
{
int r,p,m,b,n,rev,a,c,i,z;
r=0;
rev=0;
clrscr();
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);
getch();
}

3 comments: