Computer Science, asked by Anuku04468, 1 year ago

plz write a program for atomorphic with array ........plz do pzzzzz....

Answers

Answered by anuragkumar1067
0
import java.util.*;

public class Automorphic

{

    public static void main()

    {

        Scanner sc = new Scanner(System.in);

        int n, c=0, n2, sq, pow;

        System.out.print("Enter the number: ");

        n = sc.nextInt();       //Taking input

        n2 = n;                 //Initialising copy

        sq = n*n;               //Storing square

        while(n>0)

        {

            n = n/10;           //Counting the number of digits

            c++;

        }

        pow = (int)Math.pow(10, c); //Type casting

        if(sq%pow == n2)        //sq%pow gives the last c digits from the end of a square

            System.out.println("The number is an automorphic number");

        else

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

    }

}




Hiii

Anuku04468: i want in array
Answered by piyushatre29
0

#include <iostream>

using namespace std;

 

int main() {

   int n;

   int num;

   long int sq;

   int r;//remainder

   int t;//divisor - 10, 100, 1000 etc.

   int equal;//for checking

   

   cout<<"Enter a number: ";

   cin>>n;

   num = n;

   sq = n * n;

   t = 10;

   

   cout<<"\nSquare of "<<n<<" is "<<sq<<endl;

   while(n > 0)

   {

       r = sq % t;

       if(num == r)

       {

           equal = 1;

           break;

       }

       n = n / 10;

       t = t * 10;

   }

   if(equal == 1)

   {

       cout<<num<<" is an Automorphic number.";

   }

   else

   {

       cout<<num<<" is not an Automorphic number.";

   }

return 0;

}

please mark as brainleist


piyushatre29: hello frnd if this program will help u please don't forgot to mark brainleist
Similar questions