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 |
What is difference == and === in javascript?
What is the data type of variables in javascript?
What is the meaning of callback function?
What is the difference between Local Storage and Session Storage?
What is the dollar sign in javascript?
How to loop through array in javascript?
What are 2 (shorthand) boolean operators supported by javascript
What are events in javascript?
What is a null variable in javascript?
What is break and continue statements?
what is onfocus and onblur events in java script?
What is an empty html tag?