Driver Code
int main ( ) { int arr [ ] = { 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 } ; int queries = 3 ; int q [ ] [ 2 ] = { { 2 , 4 } , { 2 , 6 } , { 5 , 8 } } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; for ( int i = 0 ; i < queries ; i ++ ) cout << ( findSum ( arr , n , q [ i ] [ 0 ] , q [ i ] [ 1 ] ) ) << endl ; return 0 ; }