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.
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 |
Name some of the JavaScript features?
Where javascript variables are stored?
How to you change the title of the page by javascript?
what is the extension of java script.
How to validate email in javascript?
print the following using loop. 54321 4321 321 21 1
2 Answers Delhi Public School,
What are the seven data types of javascript?
Define unescape() function?
Explain the different types of pop-up boxes you can create in JavaScript.
Where do I put javascript code in html?
What is unobtrusive javascript? How to add behavior to an element using javascript?
Can we learn javascript without knowing java?