Program to print first 10 automorphic number

The following program prints first 10 automorphic number.  I am giving you all brief introduction about what actually automorphic numbers are, assuming that some of you might not be aware about that.  In mathematics an automorphic number (sometimes referred to as a circular number) is a number whose square “ends” in the same digits as number itself. For example, 52 = 25, 62 = 36, 762 = 5776.  First 10 automorphic number are : 1, 5, 6, 25, 76, 376, 625, 9376, 90625, 109376.

I think now all know about automorphic number and all are set to learn how to make the program  that print first 10 automorphic number.

#include<stdio.h>

void main()
{

int i,count=0;
long int n,no=0,s,rem=0,ans=0,temp;

clrscr();

printf(” First 10 automorphic number are:\n”);

for(i=1;count<10;i++)
{
n=i;

s=n*n;
temp=10;

while(n>0)
{
rem=s%temp;

if(i==rem)
{
ans=1;
break;
}
n=n/10;
temp=temp*10;
}

if(ans==1)
{
printf(“\n%d “,i);
count++;
}
ans=0;

}
getch();

}

resume

Mohit Arora
Follow me