Computer Science, asked by deepak2622, 10 months ago

write a Java Program on palindrome


neelbhatkar3: palindrome of numbers or palindrome of strings?which one?i mean to say 21-12 or Deep-peed?which one?

Answers

Answered by lastbenchstudent
0

algorithem

Get the number to check for palindrome

Hold the number in temporary variable

Reverse the number

Compare the temporary number with reversed number

If both numbers are same, print "palindrome number"

Else print "not palindrome number"

class PalindromeExample{

public static void main(String args[]){

int r,sum=0,temp;

int n=454;//It is the number variable to be checked for palindrome

temp=n;

while(n>0){

r=n%10; //getting remainder

sum=(sum*10)+r;

n=n/10;

}

if(temp==sum)

System.out.println("palindrome number ");

else

System.out.println("not palindrome");

}

}

Similar questions