My code basically arranged the number into reverse order for example 415 the program will arrange it into 514 well my code is correct but I have a problem the output should be vertical.
expected output 5 1 4
import java.util.Scanner;
public class Main{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int rev=0;
while( num != 0 )
{
rev = rev * 10;
rev = rev + num%10;
num = num/10;
}
System.out.println(rev);
}
}