title: Multiplication in a range
body: <p>I have an array to 10 numbers supprse A[10] = {1,2,3,4,5,6,7,8,9,10}
  and I have to compute the multiplication of numbers in a particular range but not getting correct answer, I am using segment tree and dont know how to use query operation
  Here is my code :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #define m 1000000000
  #define MAX 100010
  
  typedef unsigned long long ull;
  ull a[MAX];
  ull tree[4*MAX];
  
  void build_tree(int n,int b,int e){
      if(b&gt;e)return ;
      else if(b==e){
          tree[n] = a[b];
          return ;
      }
      build_tree(n*2,b,(b+e)/2);
      build_tree(n*2+1,(b+e)/2+1,e);
      tree[n] =( tree[n*2]%m * tree[n*2 + 1]%m )%m;
  }
  
  
  ull query(int index, int ss, int se, int qs, int qe)
    {
        ull p1, p2,p;
        if (qs &gt; se || qe &lt; ss)
            return -1;
  
        if (ss &gt;= qs &amp;&amp; se &lt;= qe)
            return tree[index];
        p1 = query(2 * index, ss, (ss + se) / 2, qs, qe);
        p2 = query(2 * index + 1, (ss + se) / 2 + 1, se,qs, qe);
        printf("\np1 = %d   p2 = %d",p1,p2);
        p=(tree[p1]%m*tree[p2]%m)%m;
        return p;
  
  }
  int main(){
      int n,i,query_start,query_end,segment_start,segment_end,index;
      ull value;
      scanf("%d",&amp;n);
      for(i=0;i&lt;n;i++)
         scanf("%lld",&amp;a[i]);
      build_tree(1,0,n-1);
      query_start=1;
      query_end=2;
      segment_start=0;
      segment_end = n-1;
      index=1;
      printf("Tree Formed :-\n");
      for(i=0;i&lt;n*4;i++)
            printf("%d  ",tree[i]);
      printf("\n\n");
      value=query(index,segment_start,segment_end,query_start,query_end);
      printf("\nvalue = %lld\n",value);
      return 0;
  }
  </code></pre>