Driver Code
let arr = [ 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 ] ; let queries = 3 ; let q = [ [ 2 , 4 ] , [ 2 , 6 ] , [ 5 , 6 ] ] ; let n = arr . length ; for ( let i = 0 ; i < queries ; i ++ ) document . write ( findSum ( arr , n , q [ i ] [ 0 ] , q [ i ] [ 1 ] ) + " " ) ;