Q:

Write a program in C to check if a number is Authomorphic or not a Authomorphic number

0

Write a program in C to check if a number is Authomorphic or not

----------------------------------------------------------------
Expected Output :
Input a number: 76
The given number is an Automorphic Number.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

# include <stdio.h>
# include <stdlib.h>
# include <stdbool.h>

bool chkAutomor(int num1)
{
    int sqno = num1 * num1;
    while (num1 > 0)
    {
        if (num1 % 10 != sqno % 10)
            return false;
        num1 /= 10;
        sqno /= 10;
    }
    return true;
}
int main()
{
    int auno;
 printf("\n\n Check whether a number is an Authomorphic Number or not: \n");
 printf(" ------------------------------------------------------------\n");
 printf(" Input a number: ");
 scanf("%d",&auno);	
 
      if( chkAutomor(auno))
        printf(" The given number is an Automorphic Number.\n");
    else
        printf(" The given number is not an Authomorphic Number.\n");
    return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now