Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the difference between a method and a function in alice?

1110


Which command from the jdk compiles a java program?

927


What is a flag variable?

925


What is tcp ip in java?

1069


What is difference between word and integer?

1022


What does localhost mean?

895


Tell me how many ways are there to initialise an integer with a constant.

1068


Can a static member function access member variable of an object?

965


Can constructor be protected in java?

912


What is difference between equal and == in java?

911


Why wait(),notify(),notifyAll() methods defined in Object class althought we are using in only threads.

2774


Why should I use abstract class?

1025


What is vector capacity in java?

1039


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

1016


Which is fastest collection in java?

1012