Number of Digits in a ^ b | CPP Program to calculate no . of digits in a ^ b ; function to calculate number of digits in a ^ b ; driver program
#include <iostream> NEW_LINE #include <math.h> NEW_LINE using namespace std ; int no_of_digit ( int a , int b ) { return ( ( int ) ( b * log10 ( a ) ) + 1 ) ; } int main ( ) { int a = 2 , b = 100 ; cout << " no . ▁ of ▁ digits ▁ = ▁ " << no_of_digit ( a , b ) ; }