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 difference between attributes and property?

0 Answers  


what is the difference between window & document in javascript?

0 Answers  


What does "1"+2+3 evaluate to?

0 Answers  


How to get value from radiobuttonlist control?

0 Answers  


Which built-in method sorts the elements of an array?

0 Answers  






Explain with an example the use of event handlers in javascript.

0 Answers  


What is the difference between undefined and object?

0 Answers  


What is use of settimeout function in javascript?

0 Answers  


What is the use of ‘debugger’ keyword in javascript code?

0 Answers  


What does “1?+2+4 Evaluate to? What about 5 + 4 + “3??

0 Answers  


What is new keyword in javascript?

0 Answers  


Auto insurance project..How to explain project in interviews.Using Automation tool (selenium).

0 Answers  


Categories