Write a program that inputs a 5-digit integer from the
keyboard and prints if the input number is a palindrome or
not. A palindrome is a number which has the same digit from
either end.



Write a program that inputs a 5-digit integer from the keyboard and prints if the input number is ..

Answer / vinit

import java.io.*;
public class HelloWorld{

public static void main(String []args)throws IOException{

//System.out.println("Hello World");
int n;
int t;
int cpy;
int r,rev;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
t=Integer.parseInt(br.readLine());
while(t!=0)
{rev=0;
n=Integer.parseInt(br.readLine());
cpy=n;
while(n!=0)
{
r=n%10;
n=n/10;
rev=(rev*10)+r;
}


if(rev==cpy)
{System.out.println("palindrome");
t--;
continue;}
else{
System.out.println("not Palindrome");t--;
continue;
}

}
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

What is the use of math object in javascript?

0 Answers  


What is jscript used for?

0 Answers  


Should you disable javascript?

0 Answers  


What is the best site to learn javascript?

0 Answers  


Does javascript care about whitespace?

0 Answers  






What boolean operators does JavaScript support?

5 Answers   Aptech, HCL, Satyam,


How to set the cursor to wait in JavaScript?

0 Answers  


What are the main functions performed by javascript statements?

0 Answers  


What is memory leak in javascript?

0 Answers  


What are the problems associated with using javascript, and are there javascript techniques that you discourage?

0 Answers  


how to activate and deactivate the constraint with all the default values

0 Answers  


What is the purpose of local variables?

0 Answers  


Categories