Advertisement
Aniket_Goku

no reverse in java

Feb 8th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class p3
  3. {
  4.  
  5.     public static void main(String args[])
  6.     {
  7.         Scanner se=new Scanner(System.in);
  8.         int a,b,temp,ans=0;
  9.         System.out.println(" Enter the value: ");
  10.         a=se.nextInt();
  11.         temp=a;
  12.         while(temp!=0)
  13.         {  
  14.             b=temp%10;
  15.             ans=(ans*10)+b;
  16.             temp=temp/10;
  17.         }  
  18.         System.out.println(a+"  revers->  "+ans);
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement