An output accumulator for Math Quiz in C++
<p>Ok, so I am creating a Math Quiz.  Just something basic for now, but at the end of my while loop I want to accumulate the output, meaning if you do 5 questions of addition, the output will store the expressions of all 5 questions and use a conditional operator to say if the answer is Correct or Wrong, and it will be displayed at the very end.</p>

<p>I have the same program in Java, but I want to switch it over to C++ since I really like C++, and desire more of it, and that is why I would like to figure this one out.</p>

<p>Java:</p>

<pre><code>output += "\n" + number1 + " - " + number2 + " = " + answer + ((number1 - number2 == answer) ? " CORRECT" : " WRONG");
</code></pre>

<p>My while loop w/ the output accumulator in C++:</p>

<pre><code>while (count &lt;= NUMBER_OF_QUESTIONS) {

    num1 = 1 + rand() % 50;
    num2 = 1 + rand() % 50;

    if (num1 &lt; num2) {
        temp = num2;
        num2 = num1;
        num1 = temp;
    }

    cout &lt;&lt; "\n"&lt;&lt; num1 &lt;&lt; " + " &lt;&lt; num2 &lt;&lt; " = " &lt;&lt; endl;
    cin &gt;&gt; answer;

    if (num1 + num2 == answer) {
        cout &lt;&lt; "Right!" &lt;&lt; endl;
        correctCount++;
    }
    else
        cout &lt;&lt; "Wrong! Should be " &lt;&lt; (num1 + num2) &lt;&lt; endl;

// Increase count
count++;

    // Prepare all questions if correct or wrong, for output
    output += // The rest...
} 

//and for final output

cout &lt;&lt; output;
</code></pre>
