Write a program to display numeric value in reverse order.
Ex: I have given a number like 7584, It should display in
reverse order like 4857.
Answer Posted / srikanth
import java.io.*;
class palin{
public static void main(String as[]){
try{
InputStreamReader isr=null;
BufferedReader br=null;
br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine());
System.out.println(num);
int n=num;
int rev=0;
System.out.println("number");
System.out.println(num);
for(int i=0;i<=num;i++){
int r=num%10;
num=num/10;
rev=rev*10+r;
i=0;
}
System.out.println("after reversing"+rev);
if(n==rev){
System.out.println("number is palic");
}
else{
System.out.println("number is not palic");
}
}catch(Exception e){
System.out.println(e);
}
}
}
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is java listener?
What is difference between java and core?
What is deployer?
Give some advantages of orm (object-relational mapping)?
What is application component provider?
What are j2ee components?
What is java developer?
What is devops in java?
What is container-managed persistence?
What are the component of java?
What does enterprise javabeans module contain?
What is caller?
What is j2ee explain the component of j2ee application?
How do you run a java program?
What is the difference between java and core java?