22. Reverse the number and find number is Pallindrome or not.

Pallindrome Number : - If the reverse of the 
number is eqal to original number then , the
number is pallindrome.
ex:- original number = 121  , reverse number = = 121
therefore 121 is pallindrome.
int r,n;
int rev=0;
Scanner sc = new Scanner(System.in);
n= sc.nextInt();
int number =n; // to not lost original number
while (n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
System.out.println(rev);
if (rev==number)
{
System.out.println("Number is pallindrome");
}
else

System.out.println("Number is not pallindrome"); 

output :-                       

121                               

121                               

Number is pallindrome

Comments

Popular posts from this blog

the distance between two cities (in km is input through the keyboard. write a program to convert and print this distance in meter ,feet inches and centimeter.

CREATE UNIT CONVERTER APP

write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees