Computer Science, asked by kenneth90, 1 year ago

write a program to check weather it is a karoker number​


mn121: What is a karoker number
kenneth90: sorry not karoker kaprekar number

Answers

Answered by mn121
1

import java.util.*;

public class kaprekar

{

   public static void main(String args[])

   {

       Scanner in = new Scanner(System.in);

       int n,i,sq,d=0,r,q,c=0;

       System.out.println("Enter a number = ");

       n=in.nextInt();

       sq=n*n;

       for(i=sq;i!=0;i=i/10)

       {

           d++;

       }

       for(i=1;i<d;i++)

        {

           r=sq%(int)(Math.pow(10,i));

           q=sq/(int)(Math.pow(10,i));

           if(r==0||q==0)

           continue;

           if(n==(r+q))

           c++;

        }

        if(c!=0)

        System.out.println(n+" is a kaprekar number");

        else

        System.out.println(n+"is not a kaprekar number");

      }

   }


mn121: please mark it as brainliest...
sanchari46: Thankss
mn121: ur wlcm
Similar questions