REVERSING A NUMBER

Write a program to reverse a number using a loop.

import java.util.*;

class E3SeperateNumbersLoop

{

    public static void main()

    {

        int x;

        int reverse=0;

        System.out.println("Enter any integer \n\n\n");

        Scanner in = new Scanner(System.in);

        x = in.nextInt();

        

        while(x>0)

        {

            reverse= reverse*10 + x%10; 

            x=x/10;

        }

        System.out.print("Reversed number \t" + reverse);

    }

}




For Any Desired Program comment below. WE WILL TRY OUR BEST TO MAKE THAT PROGRAM AVAILABLE.

Comments

Popular Posts