Number Reversal

Number Reversal
public class NumberReversal{
 public void reverseAndPrintNumbers(long n)
 {
   long reverseNum=0;
   while(n > 0)
   {
    long r = n%10;
    reverseNum =reverseNum*10+r;
    n/=10; 
   }
   System.out.println("Reverse Number : = "+reverseNum);
 }
}

Reactions

Post a Comment

0 Comments