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 j2ee component?
What is a java developer?
What is java netbeans?
What is containers in java?
What is container-managed persistence?
What is jaap?
What is data?
What are the main components of the j2ee application?
What is difference between javac and java?
What is webservices in java?
What does java awt stand for?
What is a j2ee component?
How will you explain load() and get() methods?
What is setbounds in java?
Is java is fully object oriented?