#include main(){int n;clrscr();puts("ENTER ANY NUMBER");scanf("%d",&n);if (n*n%10==n || n*n%100==n || n*n%1000==n)puts("THIS IS AN AUTOMORPHIC NUMBER");elseputs("THIS IS NOT AN AUTOMORPHIC NUMBER");getch();}
this can be used for any no# include # include # include int main(){ int n,no,count,rem; long int nsq; count=0; clrscr(); printf("\nenter no:"); scanf("%d",&n); no=n; while(no!=0){ no/=10; count++; } printf("\nno of digits:%d",count); nsq=n*n; rem=pow(10,count); if(nsq%rem==n) printf("\ngiven no is automorphic"); else printf("\n given no is not a automorphic no"); getch(); return 0;}
This comment has been removed by the author.
this can be used for any no
ReplyDelete# include
# include
# include
int main()
{
int n,no,count,rem;
long int nsq;
count=0;
clrscr();
printf("\nenter no:");
scanf("%d",&n);
no=n;
while(no!=0){
no/=10;
count++;
}
printf("\nno of digits:%d",count);
nsq=n*n;
rem=pow(10,count);
if(nsq%rem==n)
printf("\ngiven no is automorphic");
else
printf("\n given no is not a automorphic no");
getch();
return 0;
}
This comment has been removed by the author.
Delete