Automorphic Number in C Programming || Learning Duniya
What will be the programming of Automorphic Number?
Today we are going to learn about the Automorphic Number. We will learn definition , some example, programming and logic behind the Automorphic Number and also look at the output either input number is Automorphic Number or not.
What is Automorphic Number?
Automorphic Number is a such type of mathematical number whose square end is equal to the original number. Means if you square the number then the end of that number is equal to original number.
Example:- Lets take 5. Then square of it is 25 and this numbers ends with 5 , and last number is equal to original number. Another example 7. Then the square of this number is 49 and end number is 9, which is not equal to the original number.
Programming :-
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int num, temp,sqrNum, count,last,temp1; //Data type decelaration
printf("Enter the number");
scanf("%d",&num); //User input
sqrNum = num *num; //Squaring the number
temp1 = num;
while(temp1>0) //loop for finding digit in that number
{
temp1 = temp1/ 10;
count++;
}
temp = pow(10, count); //powering 10 to count
last = sqrNum%temp; //Finding the last digit as remainder.
if(last == num) //Condition for checking the number.
{
printf("Automorphic number");
}
else
{
printf("Not Automorphic number");
}
getch();
return 0;
}
Output:-
Fig:-1
Fig:-2
Logic :-
As definition of the Automorphic Number that when we square a number then the end of the number is equal to original number then it is Automorphic Number. For squaring the number we have multiply both number, then we have use a while loop for counting the digit of that number. After that we use pow function to find the power of 10, then finding the reminder of square and comparing with the original number if both are same or equal then printing Automorphic Number if not then Not Automorphic Number.
If you face any problem while executing the program or in the logic then comment in comment section or visit my YouTube Channel. All video are in Hindi language.
It is very helpful ...thank you so much ...
ReplyDeleteLots of best wishes 😍💐👍