Reverse of number

 import java.util.*;


class reverseofnumber{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter the number");
        int k= sc.nextInt();
        int rev=0;

        while(k!=0){

            int n=k%10;
            rev= rev*10 +n;
            k=k/10;
        }
       
        System.out.println("Reverse of number is "+rev);

    }

}

Comments

Popular posts from this blog

Convert first letter to capital letter in java

Stair case traversal search

Palindrome of string my logic