OneCompiler

1. Print each digits from starting of a given number.

133

public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

  int ndash = n;
  int pow = 1;
  
  while(ndash>=10){
    ndash = ndash/10;
    pow = pow*10;
    
  }
  
  while(pow>0){
    int firstdigit = n/pow;
    System.out.println(firstdigit);
    n= n%pow;
    
    pow=pow/10;
  }

}