Respuesta :
Answer:
The program to this question can be given as:
Program:
#include<iostream>//header file.
using namespace std; //using name namespace
void number(int n) //define function
{
int temp,s,c=1; //define variable.
temp=n; //holding value in temp variable.
s=n*n; // calculate square.
while (n!=0) //loop
{
//calculating value.
c=c*10;
n=n/10;
}
if(s%c==temp) //if block
{
cout<<"Automorphic Number"; //print message.
}
else //else block
{
cout<<"Not Automorphic Number"; //print message.
}
}
int main() //main method
{
int n; //define variable n.
cout<<"Enter a number :"; //message
cin>> n; //input value.
number(n); //calling function.
return 0;
}
Output:
Enter a number :5
Automorphic Number
Explanation:
An Automorphic number is a value in which the square end has the same numbers as a number itself. The explanation of the above program as follows:
- In the above automorphic number program, we define a function that is "number()" in the function, we pass variable n that is integer. Inside a function, we define a variable that is "temp, s, and c". The temp variable is used to for copy the number, s, and c variable is used for calculating the automorphic number.
- In the function, we define a loop that is "while loop" it entry control loop, in loop we define a conditional statement that checks that the calculated value which holds variable s and temp value is equal or not if condition is true, it will print "Automorphic Number" else it will print "Not Automorphic Number".
- Then we define the main method in the method we define a variable n and take value-form user and pass value to function then we call the function.