Automorphic number in c for beginners. A number is said to be automorphic if its square equals the supplied number, for example, (25)2 = 625 and (76)2 = 5776.

Square Function in Automorphic Number

Math. h header file contains a definition for the sqrt() . You may explicitly convert a data type to double using the cast operator in order to determine the square root of an int, float, or long double. sqrt(double(x)); int x = 0; double result;

How While Loop is Used in Automorphic Number

Math. h header file contains a definition for the sqrt() function. You may explicitly convert a data type to double using the cast operator in order to determine the square root of an int, float, or long double. sqrt(double(x)); int x = 0; double result;

Pow Function in C

The power of an integer is calculated using the pow() function. The power raised to the base number is returned by the pow() function, which accepts two parameters (the base value and the power value).

Automorphic Number in C

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int a, sqr, temp, last;
int n =0;
printf("Enter The Number\n");
scanf("%d",&a);
sqr = a*a;
temp = a;
while(temp>0)
{
n++;
temp = temp/10;
}
int den = floor(pow(10,n));
last = sqr % den;
if(last == a)
printf("Automorphic Number\n");
else
printf("Not Automorphic Number\n");
return 0;
}