C Online Compiler
Example: Check Whether a Number is Automorphic Number or Not in C using Function
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Check Whether a Number is Automorphic Number or Not in C using Function #include <stdio.h> int isAutomorphic(int x); // It's the driver function int main() { int x; // x - denotes the input number to check printf("-----Enter an input number to check, It's an automorphic-----\n"); scanf("%d", &x); //checking condition if (isAutomorphic(x)) { printf("\nThis is an automorphic number\n"); } else { printf("\nThis is not an automorphic number\n"); } return 0; } // This function will check number itself int isAutomorphic(int x) { int sq = x * x; // sq - denotes the square while (x > 0) { if (x % 10 != sq % 10) return 0; // Reduce N and square x = x / 10; sq = sq / 10; } return 1; }
456
Output
Clear
ADVERTISEMENTS