Program to compute log a to any base b ( logb a ) | C ++ program to find log ( a ) on any base b ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int log_a_to_base_b ( int a , int b ) { return log ( a ) / log ( b ) ; } int main ( ) { int a = 3 ; int b = 2 ; cout << log_a_to_base_b ( a , b ) << endl ; a = 256 ; b = 4 ; cout << log_a_to_base_b ( a , b ) << endl ; return 0 ; }