even number sum

can anyone help solving this program..."write a program to sum all even numbers from 1 to 100"

thank you
You should do your own homework. Think about how you would do this yourself using pen and paper, then translate it into code and if you got problems, you can ask questions on this forum.
Nobody will just give you the code you need, certainly not if you're asking it the way you do (without even trying to do it yourself).
http://www.cplusplus.com/forum/articles/1295/
Well some people just can't find the info, and maybe this guy is just starting to program you never know. Either way, what you are going to need is some simple if statements using modulus (%). In case you don't know, modulus divides one number by another, except the result is the remainder. For example 9%2=1. Any even number can always be divided perfectly by two, but an odd number can never be, and theres your answer.
Last edited on
@epiqu1n: No. The OP is just being lazy. There are tutorials on this site, and google has hundreds of thousands of articles on C++. This was not a question, but a request for someone to do their homework.

We do not entertain such requests.
Maybe Epiqu1n is just a nice guy trying to help a bud out, ever think of that big guy?
Being nice does not translate to giving answers (which could be considered cheating).
Agreed with firedraco. Epiqu1n is being nice, but the result is that the OP is just abusing that fact, and wont do his homework next time either.

When you'll read more postes like this you will understand what we mean.
just research modulus
Last edited on
wow belkdaddy
we have like the same screename!
we must be twins or something
Ok I changed it so the code isn't there even though it's probably too late, actually sorry though I didn't realize I posted the whole thing I thought there was more to it besides the if statement. But it doesn't hurt to just help them understand the concept with a short example, so that way they at least have to understand it to get it to work.
@epiqu1n

You dont have to feel gulty or someting. You're right that sometimes it is good to post code to show how it works, but you need to understand that there are differences between questions. Some people actually have tried to solve it themself, have done some resource and tried it again, but simply cant figure out the problem. Those people you should help as much as possible.
Other people are just being lazy, and dont want to make there homework, so they simply post there assigment and hope someone will give them the code. They havent even tried to solve it. You shouldnt help those people, cause they're not worth it.
Last edited on
Topic archived. No new replies allowed.