Write the code for Palindrome ?
Answer Posted / suresh royal
mport java.io.*;
public class Palindrome {
public static void main(String [] args){
try{
BufferedReader object = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter number");
int num= Integer.parseInt(object.readLine());
int n = num;
int rev=0;
System.out.println("Number: ");
System.out.println(" "+ num);
for (int i=0; i<=num; i++){
int r=num%10;
num=num/10;
rev=rev*10+r;
i=0;
}
System.out.println("After reversing the number: "+ " ");
System.out.println(" "+ rev);
if(n == rev){
System.out.print("Number is palindrome!");
}
else{
System.out.println("Number is not palindrome!");
}
}
catch(Exception e){
System.out.println("Out of range!");
}
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do you use find and replace?
Which is better ascii or unicode?
What is method overriding in java ?
What are the disadvantages of using inner classes?
What are the types of java?
How do you use parseint in java?
How to print nodes of a Binary tree?
What are keywords and reserved words in java?
What is a get method?
When will you define a method as static?
Why are variables important in research?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What is data member in java?
Can an interface be final?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?