## Description

## Write a c program to find the given number is Automorphic number or Not.

An **automorphic number** is a number that has the same digit at the end of the square as the given number is an automorphic number. For Example : 25 is a Automorphic Number.

Let's check that 25 is a automorphic number.

Square of 25 is 625 , so ends digits of 625 is 25 , is same to given number, 25 is the automorphic number.

Now let's code this program...

```
#include<stdio.h>
int main(){
int n;
printf("Enter the number : ");
scanf("%d", &n);
// Calculate the square
long int sq = n * n;
int d = 10; // divisor
int temp = n, remainder, flag = 0;
while(temp>0){
remainder = sq % d;
if(n == remainder){
flag = 1;
break;
}
temp = temp/10;
d = d * 10;
}
if(flag==1){
printf("%d is an Automorphic Number", n);
}else{
printf("%d is Not an Automorphic Number", n);
}
return 0;
}
```

## Output :

Enter the number : 76

76 is an Automorphic Number

**How it's work?**

First created a variable named 'n' which stores the input given from the user. Then printed a message for the user so that the user would know what to do now and took input from user through **scanf() function**. Afer that we declare some more variables which have thier own different functions. 'sq' long int variable declared , sq is store the value of square the given number, and int data type variable 'd' is used for divisior, 'temp' variable is a temporary variable which store the real value of given number by user, 'remainder' variable store the value of ( the given number of last digit), and flag variable used for the identify. Started a while loop , this loop is valid as long as the given condition is true. As long as the condition is true, it will continue to execute the statement written inside the loop body. When loop condition becomes false then loop will terminated. After this we will check with the identifier ( flag ) that if the value of flag is 1 then we can say that given number is an Automorphic Number otherwise we will say that the given number is not an automorphic number. In this way we wrote a program which tells us whether a given number is Automorphic or Not.

**Now it's Algorithem of Automorphic Number check**

**Step 1 : **CREATE 'n'

**Step 2 : **TAKE INPUT FROM USER

**Step 3 : **CREATE sq and SET sq = n * n

**Step 4 : **SET d = 10

**Step 5 : **SET temp = n, AND CREATE remainder AND flag SET flag = 1

**Step 6** : REPEAT step7 and step 8 while ( temp > 0 )

**Step 7 : ** remainder = sq % d;

**Step 8 : **CHECK THAT ( remainder == n) THEN flag = 1, AND break OTHERWISE PERFORM temp = temp / 10 AND d = d * 10.

**Step 9 : **CHECK if ( flag == 1) PRINT "Number is An Automorphic" OtHERWISE PRINT "Number is Not An Automorphic"

**Step 10 : **Exit

## Recommended Posts

## 9 basic program in cpp programming language | @lapmos

In this post we write the 9 basic program in c programming language which is based the basic understanding of c++ programming language.

## Spy Number | c programming

Today we are going to write a program which is to check if given number is spy or not and yes the most important thing is what is spy number, you will get the answer of all these on this blog.

## Display Name of the month by accepting digit of the month | c programming

We will print the month name from the month number given by the user which will give us the user input. For Example : User Entered 5 then print

## Happy Numbers | with Example And Programs

Replace the number by the sum of the squares of its digits, and repeat the process. At the end, if the number is equals to 1 then it is a Happy Number, or it loops endlessly in a cycle that does not include 1 (if it is not a happy number then this process will end at 4).

## Sunny Number in programming

A number is a sunny number. If 1 is added to that number and the square root of it becomes a whole number.

## Program to check whether number is Disarium Number

A Number is a disarium number if the sum of the digits powered with their respective positions is equal to the number itself.