AUTOMORPHIC NUMBER OR NOT

    

 

Consider the following I/O samples.


SAMPLE INPUT: 5

SAMPLE OUTPUT:  AUTOMORPHIC NUMBER


A number is called a AUTOMORPHIC NUMBER if and only if the square of the given number ends with the same number itself.


76^2 = 5776


C PROGRAM:

#include<stdio.h>

int main()

{

    int num, sqr, temp, last,count=0,den;

    scanf("%d",&num);

    sqr = num*num;  

    temp = num;

    while(temp>0)

    {

        count++;

        temp = temp/10;

    }

    den = floor(pow(10,count));

    last = sqr % den;

 

    if(last == num)

        printf("Automorphic number");

    else

        printf("Not Automorphic");

    return 0;

}


OUTPUT:





The given source code in C program "FOR AUTOMORPHIC NUMBER OR NOT" is short and simple to understand. The source code is well tested in DEV-C++ and is completely error free. 

If you have any feedback about this article and want to improve this, please write to                                                                nivisonu23@gmail.com


Comments

Popular posts from this blog

INVERTED PYRAMID STAR PATTERN

C PROGRAM TO PRINT ALL LEAP YEARS IN A GIVEN RANGE

C PROGRAM TO PRINT THE REMAINING DAYS AND COMPLETED DAYS FROM A GIVEN DATE