segment tree

can anyone provide me with the updateTreenode function if we have to update all elements from l to r

using the above method only and little modification

Updating elements in range is done by lazy propagation. You will have to create another array as large as segment tree. Briefly, if the whole node falls in range for update, you don’t update all the children of that node, instead you simply update the node and propagate the value to its children which will be taken into account when needed(i.e when we need to update the children or query them).
I know I am bad at explaining. You can read about it here. In case of any doubts feel free to ask!

You can have a look on the following problems and their respective solutions :

  1. Sum of Squares
    Question
    Solution

  2. Horrible Queries
    Question
    Solution

  3. Ahoy Pirates
    Question
    Solution

This technique is called Lazy Propagation link

In my opinion, geeksforgeeks rarely has good quality content and when it does it is often not original. If you scroll down to the bottom you will the link from where the author has copied the article: http://codeforces.com/blog/entry/18051

Here you will find the modification needed for range updates.