- 1
write a java program for palindrome
2 Réponses
+ 1
palindrome for num or string??
0
//Palindrome for Numbers
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int rem,sum=0,n,temp;
System.out.println("Enter the value");
n=input.nextInt();
temp=n;
while(n!=0) {
rem=n%10;
sum=(sum*10)+rem;
n=n/10;
}
if(sum==temp){
System.out.println(sum+"\t is palindrome");
}
else {
System.out.println("Given value is not palindrome ");
}
}
}