Solving the Lazy Hobo Riddle
Notice how the square of a number 15 or greater exceeds 200? What you can do, is set the interval from 1 to 14.
There is no advantage in evaluating the same combination over and over again. Realize that the most efficient way is to structure your for loops such that 

$$ a  \leq b  \leq c  \leq d $$

In your attempt, you are iterating 38,416 times!

By limiting the interval, you iterate just 2380 times! 

One more thing you can do: check and break when \$a^{2} + b^{2} + c^{2} + d^{2} &gt; 200 \$

for(int a = 1; a&lt;=14; a++)
    for(int b = a; b&lt;=14; b++)
        for(int c = b; c&lt;=14; c++)
            for(int d = c; d&lt;=14; d++){
                if(a*a + b*b + c*c + d*d == 200)
                    cout &lt;&lt; "a: " &lt;&lt; a &lt;&lt; " b: " &lt;&lt; b &lt;&lt; " c: " &lt;&lt; c &lt;&lt; " d: " &lt;&lt; d &lt;&lt; endl;
                else if(a*a + b*b + c*c + d*d &gt; 200)
                    break;
            }


Now you iterate only 1,214 times! This is way more efficient.