Recursive/iterative functions
<p>I'm having a bit of a hard time creating a function, using iteration and recursion to find the sum of all even integers between 1 and the number the user inputs. The program guidelines require a function to solve this three ways:</p>

<ol>
<li>a formula</li>
<li>iteration</li>
<li>recursion</li>
</ol>

<p>This is what I have so far:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cstdlib&gt;

using namespace std;

void formulaEvenSum(int num, int&amp; evenSum)
{
    evenSum = num / 2 * (num / 2 + 1);
    return;
}

void loopEvenSum(int num, int&amp; evenSum2)
{

}


int main()
{
    int num, evenSum, evenSum2;

     cout &lt;&lt; "Program to compute sum of even integers from 1 to num.";
     cout &lt;&lt; endl &lt;&lt; endl;

     cout &lt;&lt; "Enter a positive integer (or 0 to exit): ";
     cin &gt;&gt; num;

     formulaEvenSum(num, evenSum);
     loopEvenSum(num, evenSum2);

     cout &lt;&lt; "Formula result = " &lt;&lt; evenSum &lt;&lt; endl;
     cout &lt;&lt; "Iterative result = " &lt;&lt; evenSum2 &lt;&lt; endl;

     system("PAUSE");
     return 0;

}
</code></pre>
