C Program to find out the given number is automorphic or not

C Program to find out the given number is automorphic or not, Automorphism Numbers in C, automorphic Numbers finding in C



#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");

else

puts("THIS IS NOT AN AUTOMORPHIC NUMBER");

getch();

}


2 comments:

  1. 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;
    }

    ReplyDelete