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

Is it safe to use javascript?

0 Answers  


Write JavaScript code to use file system in binary format?

0 Answers  


What is the method for reading and writing a file in javascript?

0 Answers  


What are the main features of javascript?

0 Answers  


What is the use of dom?

0 Answers  






Are there any predefined constant provided by the browser with the key code values that can be reused?

0 Answers  


do any browser need activeX object to run javascripts?

2 Answers  


Is javascript a programming language?

0 Answers  


Why is var better than let?

0 Answers  


Event bubbling and Event Capturing in JavScript?

0 Answers  


What is difference between undefined variable and undeclared variable?

0 Answers  


What is Number object in JavaScript?

0 Answers  


Categories