Write you own Power without using multiplication ( * ) and division ( / ) operators | C ++ code for power function ; Works only if a >= 0 and b >= 0 ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int pow ( int a , int b ) { if ( b == 0 ) return 1 ; int answer = a ; int increment = a ; int i , j ; for ( i = 1 ; i < b ; i ++ ) { for ( j = 1 ; j < a ; j ++ ) { answer += increment ; } increment = answer ; } return answer ; } int main ( ) { cout << pow ( 5 , 3 ) ; return 0 ; }