-
Quick Help Please
:confused:
I'm not sure on how to do this program Please send your helpful results as soon as possible. I use DEV C++.
I need to write a program that will calculate the sum of even numbers between limits entered by the user. For example, if the user entered 4 and 10, the program would calculate 4+6+8+10 and print 28 as the answer. Note that the two numbers can be entered in any order and may be odd or even. Entering 11 and 3 would also result in an answer of 28.
Thank you 4 your help and response in advance.:D
-
try it, post your code, then we will be glad to help you.
-
Code:
- input 2 numbers, a, b
- order numbers so a < b
- find first even # starting at 'a' and store in 't'
- use for loop from 't' to 'b', incrementing by 2 and sum the numbers in 's'
- use % to determine if a number is even.
gg