Query Bits problem

I have partially solved the problem. the problem I am facing is:
In update function , how should i calculate the value for the tree[index] ?

I cant just left shift the tree[2index] by right range and then OR with the tree[2index+1].

Please check this and help me clarify the concept.

Take a look at this code: