title: c program to add all even numbers in array and subtract all odd numbers in array
body: <p>I am trying to write a program that returns a number which is all even numbers added to the total from the array, subtracted by all the odd numbers in the array. But I am getting 0 but the output should be 2.</p>
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdio.h&gt;
  
  int add_even_sub_odd(const int data[], int n)
  {
      int total = 0;
      for (size_t i = 0; i &lt; n; i++)
      {
          if (data[i] % 2 == 0) {
              total + data[i];
              printf(&quot;%d\n&quot;, data[i]);
          }
  
          else {
  
              total - data[i];
              printf(&quot;%d\n&quot;, data[i]);
  
          }
      }
      return total;
      
  }
  
  int main(void)
  {
      int data[4] = {1, 2, 3, 4};
      printf(&quot;%d\n&quot;, add_even_sub_odd(data, 4));
  }
  </code></pre>