- 1

write a java program for palindrome

1st Aug 2016, 12:58 PM
honey
honey - avatar
2 Réponses
+ 1
palindrome for num or string??
1st Aug 2016, 3:57 PM
Manikanth Vanka
Manikanth Vanka - avatar
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 "); } } }
1st Aug 2016, 4:08 PM
Manikanth Vanka
Manikanth Vanka - avatar