Java Program to split number into digits
Below sample program can be used to split number into digits. Here we are using a 4 digit number to do the same.
/* Program to split of a 4 digit number */ class P7 { public static void main(String args[]) { int x = 1234, y, z; y = x /1000 ; System.out.println(" The digit in the Thousand's place = "+y); z = x % 1000; y = z /100; System.out.println("\n The digit in the Hundred's place = "+y); z = z % 100; y = z / 10; System.out.println("\n The digit in the Ten's place = "+y); y = z % 10; System.out.println("\n The digit in the Unit's place = "+y); } }
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.