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 / selvi
import java.util.Scanner;
public class IntReverseOrder
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
StringBuffer sb = new StringBuffer();
int remainder;
while(num>0)
{
remainder = num%10;
sb = sb.append(remainder);
num = num/10;
}
System.out.println("Reverse Order = "+sb);
}
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is document root?
Why class is used in java?
What is java developer?
What is the difference between java and core java?
What do you understand by connector?
What are the component of java?
What is assembly in java?
What is pure java?
What is java 2 platform, standard edition (j2se)?
What is callback methods?
What is external subset?
What every java developer should know?
What is credentials?
What is awt package in java?
What does the application client module contain?