Friday, 10 January 2014

A program in C++ using classes to find out whether the entered number is automorphic or not.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{int n,r=0,i,s=0,m,a,b,l,k=0;
cout<<"enter a number";
clrscr();
cin>>n;
l=n;
 while(l!=0)
 {r=l%10;
 s=s+1;
 l=l/10;
 }
 b=n*n;
 m=pow(10,s);
 k=b/m;
 a=b-m*k;
 if (a==n)
  {cout<<"automorphic number"<<n;}
 else
  {cout<<"not automorphic";}
  getch();
}




No comments:

Post a Comment