# Input a number and check if it is an automorphic number or not using a function in C++

###### Function - Question 10

In this question, we will see how to input a number and check if it is an automorphic number or not in C++ programming using a function. To know more about function click on the function lesson.

Q10) Write a program in C++ to input a number and check if it is an automorphic number or not using a function.

A number N is said to be automorphic, if its square ends in N for example 5 is automorphic, because 52=25, which ends in 5, 25 is automorphic, because 252=625, which ends in 25.

#### Program

``````#include <iostream>
#include <conio.h>

using namespace std;

int automorphic(int num)
{
int x,t,s;
x=1;
t=num;
while(t>0)
{
x=x*10;
t=t/10;
}

s=num*num;   // square of the number
if(s%x==num)
{
return 1;
}
return 0;
}

int main()
{
int n;
cout<<"Enter a number ";
cin>>n;
if(automorphic(n)==1)
{
cout<<"Automorphic Number";
}
else
{
cout<<"Automorphic Number";
}
return 0;
}``````

#### Output

```Enter a number 25
Automorphic Number```