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.

Tuesday 20 August 2013

C++ program to check whether the given number is Adam Number or not

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int r,p,m,b,n,rev,a,c,i,z;
r=0;
rev=0;
cout<<"Enter any number between 10 and 100: ";
cin>>z;
n=z;
c=n*n;
while(n!=0)
{
m=n%10;
r=r*10+m;
n=n/10;
}
cout<<"\n"<<"The square of "<<z<<"is "<<c;
cout<<"\n"<<"The reverse of "<<z<<"is "<<r;
p=r*r;
cout<<"\n"<<"The square of "<<r<<"is "<<p;
while(c!=0)
{
a=c%10;
rev=rev*10+a;
c=c/10;
}
if(rev==p)
cout<<"\n"<<z<<" is an Adam Number";
else
cout<<"\n"<<z<<" is not an Adam Number";
getch();
}


1 comment: