Computer Science, asked by abhijithr4813, 10 months ago

Write a program to check whether a no. Is automorphic or not?

Answers

Answered by devasya619
0

Answer:

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

{

int num, sqr, temp, last;

int n =0;

printf("Enter a number \n");

scanf("%d",&num);

sqr = num*num;

temp = num;

while(temp>0)

{

n++;

temp = temp/10;

}

int den = floor(pow(10,n));

last = sqr % den;

if(last == num)

printf("Automorphic number \n");

else

printf("Not Automorphic \n");

return 0;

}

Answered by jithinayalloor
0

Answer:

bluej program:

import java.util.*;

class automorphic

{    

       public static void main()

       

       {  

           Scanner sc= new Scanner(System.in);

           System.out.println("enter an integer");

           int n = sc.nextInt();

           int sqr=n*n,c=0,cpy=n;

           while(n>0)

           {

               int ld=n%10;

               c++;

               n=n/10;

           }

           int automorphic=sqr%(int)Math.pow(10,c);

           if (automorphic==cpy)

           System.out.println("the number is automorphic");

           else

           System.out.println("the number is not automorphic");

       }

   }

           

           

               

           

Explanation:

Similar questions