Computer Science, asked by aarnavarora25, 28 days ago

Wap to input a three digit number and print its unit, 10th unit and 100th unit

Answers

Answered by itzhurtedboy
0

Answer:

As in this case you want to print digit in tenth position .

Second Multiply the position by 10. In this case it will become 100

Now Perform the following operation :

reminder = number % 100

now divide the reminder by the position you want(in this case it is 10)

digit = reminder / 10

Hurrah!!!! You get the digit.

Example : number = 12345

1. digit at tenth position

= ( number % 100 ) / 10

= (12345 % 100 )/10

= 4

2. digit at hundredth position

= ( number % 1000 ) / 100

= (12345 % 1000)/100

= 3

Similar questions