Find the Nth digit from right in base B of the given number in Decimal base | C ++ Implementation to find Nth digit from right in base B ; Function to compute Nth digit from right in base B ; Skip N - 1 Digits in Base B ; Nth Digit from right in Base B ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int nthDigit ( int a , int n , int b ) { for ( int i = 1 ; i < n ; i ++ ) a = a / b ; return a % b ; } int main ( ) { int a = 100 ; int n = 3 ; int b = 4 ; cout << nthDigit ( a , n , b ) ; return 0 ; }