for loop

I'm very new to c++. Just a question: in a for loop, is it possible to funnel the previous RESULT of the loop back through the loop? This is probably a very simple thing to do, but I'm obviously over-thinking it.
Not sure what you mean. What exactly do you mean by "RESULT"?
As you're new to C++, I don't know how much you know. But if you use a function, this can be done easily.

If you want the result of a loop to go through the same loop, you'll have to have two loops, one after another. Just, in the second loop, use the variable that was changed in the first.

Hope this helps (:
@Peter87 - sorry about not being so clear. But I think Lynx876 got it.
@Lynx876 - Thank you! This does help. Another question: if you want the result to go through more than twice, say, 20 times, is there a way to do that simpler than typing out the loop 20 times?
You can put the loop inside another loop.
int sum = 0;
for (int i = 0; i < 20; ++i)
	for (int j = 0; j < 5; ++j)
		sum += j;
	std::cout << sum << std::endl;
Thank you!!!
aha! I didn't think of nested loops! Sorry.
Topic archived. No new replies allowed.