Featured
- Get link
- X
- Other Apps
C++ program to display automorphic numbers between 1 to 1000
/* Program to display automorphic numbers between 1 to 1000. An Automorphic number is that whose square has that number in it from back. For Example: 25 the square of 25 is 625 which has 25 in it */
#include<iostream.h>
long digcount(long);
void main()
{
for(long i=1;i<=1000;i++)
{
long ten=1;
long sq=i*i;
long dc=digcount(i);
for(int k=1;k<=dc;k++)
{
ten=ten*10;
}
if(sq%ten==i)
cout<<"Automorphic Number "<<i<<"\n";
}
}
long digcount(long x)
{
long count=0;
while(x>0)
{
x=x/10;
++count;
}
return count;
}
OUTPUT:
#include<iostream.h>
long digcount(long);
void main()
{
for(long i=1;i<=1000;i++)
{
long ten=1;
long sq=i*i;
long dc=digcount(i);
for(int k=1;k<=dc;k++)
{
ten=ten*10;
}
if(sq%ten==i)
cout<<"Automorphic Number "<<i<<"\n";
}
}
long digcount(long x)
{
long count=0;
while(x>0)
{
x=x/10;
++count;
}
return count;
}
OUTPUT:
- Get link
- X
- Other Apps
Labels:
automorphic numbers program in C++
C++ program to display automorphic numbers between 1 to 1000
what is automorphic number
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment