The statement
will result in e being equal to the remainder of the division of e by 2. In other words, if e is even, e will become 0, if e is odd, e will become 1, and e will not change after that no matter how many times you loop.
To display the sum of all even numbers, you will need TWO variables, one for the sum and one for the even numbers. You should loop according to the even numbers until you get to n, add add them up using the sum.
Have a go and let us know if you need more help.
Cheers
darkagn
Reputation Points: 395
Solved Threads: 192
Veteran Poster
Offline 1,136 posts
since Aug 2007