In this article, we will write a C Program for Automorphic Number. The following C programming topic is used in the program below.
A number is said to be an automorphic number if the square of the given number ends with the same digits as the number itself. Example: 25, 76, 376, etc.

Automorphic Number Program in C
The C program to check automorphic number below takes the number from the user as input and checks accordingly.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int num;
printf("Enter the number: ");
scanf("%d", &num);
int sqr, temp, last;
int count = 0;
sqr = num * num;
temp = num;
//Counting digits
while (temp > 0)
{
count++;
temp = temp / 10;
}
//calculation
int den = floor(pow(10, count));
last = sqr % den;
//display
if (last == num)
printf("%d is an Automorphic number.", num);
else
printf("%d Not Automorphic number.", num);
return 0;
}
Output:
Enter the number: 25
25 is an Automorphic number.