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 application configuration resource file?
explain the technologies that j2ee platform provides for developing components.
What is setbounds in java?
What is java mobile?
What is Document Object Model?
What is connector?
Is java 100 percent pure object oriented?
What is the J2EE module?
Is java part of oracle?
What is java web technologies?
Which is latest technology in java?
What is architecture neutral in java?
What is event in java?
How do I become a java developer?
Is visual studio good for java?