Computer Science, asked by muskan142410, 9 months ago



5. Write a java program to print place value of ten's and thousand's digit in a number e.g., for a number
72149, it will print 2000 and 40.

Answers

Answered by ridhirajput460
0

Answer:

htdevkkydvnjfesvbmmhgbngrfhjk

Answered by nrusinghmuna
3

Answer:

public class Test{

   public static void main(String[] args){

       int num=72149;

       int ctr=-1;

       int dg=0;

       while(num!=0){

           dg=num%10;

           ctr++;

           if(ctr%2!=0){

               dg=(int)(dg*Math.pow(10,ctr));

               System.out.print(dg);

           }

           num=num/10;

           System.out.println();

       }

   }

}

Explanation:

  1. This is a simple digit programming. so, use digit code snippet.
  2. Our objective is to find 10, 1000, ... etc so 10^1, 10^3 and so on...
  3. If we start our counter from -1 then each tens and thousands will be an odd counter.
  4. So, if we detect odd counters then we can calculate digit X 10^c (c=counter)
Similar questions