Hw Help

Pages: 12
http://www.cplusplus.com/forum/beginner/209278/

Other threads are irrelevant to my point.

No you didn't. You came 12 hours after the fact.

Many threads last for days. The fact is that I did try to help in the 3rd post. The timestamp is irrelevant.
closed account (48T7M4Gy)
So how's life otherwise in beautiful (I assume) downtown Central New Jersey in the ol' US of A now that Trumps in, Davo?
Other threads are irrelevant to my point.

no they're not. a pattern of behavior is established over time and neither kemort nor I deserve what you've accused us of. we try to help, learn and sometimes have a laugh along the way but I think neither one of us bears a selective holier-than-thou attitude and each one of us is prepared to take a stand against abusive idiots as the other link, read together with this, demonstrates
The tongue in cheek answer made me laugh, its true. I have no desire to pick on anyone, but we do see a lot of verbatim HW questions with 0 effort.

Still, lets move on and get with the spirit of the thing...

-------
This is simple enough that doing it for you isnt over the top. Everyone has to start somewhere, and an example can be a good teaching tool.

a for loop has the format
for (pre-loop-action; condition to quit; loop action)
{
body
}

so to do this thing the simple way, with a simple loop, you need to add up 3 things.

int even, odd, total; //define your totals.
even=odd=total=0; //set them all to zero.
int i; //i is often used for loop counters.

for(i = 0; i < 101; i++) //101 includes 100. it stops at 101, as 101 is not less than 101
{
total += i; //running total
if (i%2 == 0) //its even
even += i; //total them up.
else
odd+=i;
}

There are other ways to do it, including direct computation of the answers. But this is probably what your professor wanted, as professors are known for asking for brute force programs early on.


Topic archived. No new replies allowed.
Pages: 12