Monday, July 27, 2020

Write a program to find Reverse of any number?(123=321)

55)       Write a program to find Reverse of any number?(123=321)


import java.util.*;
public class Reverse_number
{
    public static void main(String args[ ])
   {
              Scanner sc = new Scanner (System.in);
              System.out.println("Enter a number");
              int k = sc.nextInt();
              int r = 0;
              while(k>0)
              {
              int d = k%10;
              r=(r*10)+d;
              k=k/10;
              }
              System.out.println("REVERSE number = "+r);
   }
}

Output : 


No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj