Reverse a number

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number : "); long num = in.nextLong(); long rem; long rev = 0; while(num != 0){ rem = num % 10; rev = rev * 10 + rem; num /= 10; } System.out.println("Reverse is "+rev); } }
Editor Settings
Theme
Key bindings
Full width
Lines