Place Value of a given digit in a number | C ++ 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 .
#include <bits/stdc++.h> NEW_LINE using namespace std ; 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 ; } int main ( ) { int D = 5 ; int N = 85932 ; cout << ( placeValue ( N , D ) ) ; }