About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, April 19, 2010

JAVA(Number Palindrome or Not)--------------------------

// Palindrome Number or Not


import java.io.*;



class PalindromeNumber

{

public static void main(String []arr)

{

int num=0,ori=0,sum=0,dig=0;

System.out.println("Enter Any Number...");

try

{

DataInputStream dis=new DataInputStream(System.in);

num=Integer.parseInt(dis.readLine());

}

catch(Exception e){}



ori=num;

while(num!=0)

{

dig=num%10;

sum=sum*10+dig;

num=num/10;

}



if(sum==ori)

{

System.out.println("Number is Palindrome");

}

else

{

System.out.println("Number is Not Palindrome");

}

}

}

No comments: