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
0
Answer:
htdevkkydvnjfesvbmmhgbngrfhjk
Answered by
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:
- This is a simple digit programming. so, use digit code snippet.
- Our objective is to find 10, 1000, ... etc so and so on...
- If we start our counter from -1 then each tens and thousands will be an odd counter.
- So, if we detect odd counters then we can calculate (c=counter)
Similar questions