Thursday, 30 January 2014

WAP to enter a no. Now display it is automorphic no. or not.



import java.io.*;
class rajnish
{
public static void main(String args[])throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
int a,n,r1,r2,p,flag=0;
System.out.println("Enter a number");
a=Integer.parseInt(br.readLine());
n=a;
p=a*a;
while(n!=0)
{
r1=a%10;
r2=p%10;
if(r1!=r2)
{
flag=1;
break;
}
n=n/10;
p=p/10;
}
if(flag=0)
System.out.println(a+" is a automorphic no ");
else
System.out.println(a+" is not a automorphic no");
}
}

1 comment: