Reverse of a Number

 

Write a program to generate the reverse of a given number N. Print the corresponding reverse number.

Sample Input 1 :
1234
Sample Output 1 :
4321
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		

        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

        int r=0;
        while(n>0)
        {
           int d= n%10;
        	r=r*10+d;
            n=n/10;
            
        }
        System.out.println(r);

	}
}

Comments

Popular posts from this blog

Minimum Length Word

Check Number Sequence

Star Pattern