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 are the j2ee technologies?
Is core java and j2se same?
Which server is best for java?
What is j2ee stand for?
What is the ear file?
Describe action form?
What is application assembler?
What is application client container?
What is java api for xml processing (jaxp)?
What is the difference between load() and get()?
Describe the file types *.ear, * .jar and *.war?
What do you understand by connector? Explain connector architecture.
What are the advantages of object-relational mapping (orm)?
What is document root?
What is difference between java and core?