Larger of a ^ b or b ^ a ( a raised to power b or b raised to power a ) | C ++ code for finding greater between the a ^ b and b ^ a ; Function to find the greater value ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findGreater ( int a , int b ) { long double x = ( long double ) a * ( long double ) ( log ( ( long double ) ( b ) ) ) ; long double y = ( long double ) b * ( long double ) ( log ( ( long double ) ( a ) ) ) ; if ( y > x ) { cout << " a ^ b ▁ is ▁ greater " << endl ; } else if ( y < x ) { cout << " b ^ a ▁ is ▁ greater " << endl ; } else { cout << " Both ▁ are ▁ equal " << endl ; } } int main ( ) { int a = 3 , b = 5 , c = 2 , d = 4 ; findGreater ( a , b ) ; findGreater ( c , d ) ; return 0 ; }