Place Value of a given digit in a number | Java implementation to find place value of a number ; function to find place value ; Driver Code ; Digit , which we want to find place value . ; Number from where we want to find place value .
import java . util . * ; import java . io . * ; import java . lang . * ; class GFG { static int placeValue ( int N , int num ) { int total = 1 , value = 0 , rem = 0 ; while ( true ) { rem = N % 10 ; N = N / 10 ; if ( rem == num ) { value = total * rem ; break ; } total = total * 10 ; } return value ; } public static void main ( String [ ] args ) { int D = 5 ; int N = 85932 ; System . out . println ( placeValue ( N , D ) ) ; } }