Computer Science, asked by krishnatripathi1, 6 months ago

Write a program in java to find the reverse of a number.​

Answers

Answered by jayantip962
1

Explanation:

Reverse a Number using a while loop in Java · First, the remainder of the num divided by 10 is stored in the variable digit . · After ...

Answered by Shivu516
0

I have used reverse() function

import java.util.Scanner;

public class NumberReverser {

   int reverse = 0;

   public static void main(String [] args){

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter a number: ");

       StringBuilder number = new StringBuilder(sc.next());

       System.out.print("The reversed number is ");

       System.out.print(number.reverse());

   }

}

Output:

Enter a number: 123456789

The reversed number is 987654321

Similar questions