text: Automorphic Number | C ++ program to check if a number is Authomorphic ; Function to check Automorphic number ; Store the square ; Start Comparing digits ; Return false , if any digit of N doesn ' t ▁ ▁ match ▁ with ▁ its ▁ square ' s digits from last ; Reduce N and square ; Driver code
code: #include <iostream> NEW_LINE using namespace std ; bool isAutomorphic ( int N ) { int sq = N * N ; while ( N > 0 ) { if ( N % 10 != sq % 10 ) return false ; N /= 10 ; sq /= 10 ; } return true ; } int main ( ) { int N = 5 ; isAutomorphic ( N ) ? cout << " Automorphic " : cout << " Not ▁ Automorphic " ; return 0 ; }