Hellow...How to count and sum even and odd integers from a sequence of integers..?

Recommended Answers

sumEven=0;
sumOdd=0;

loop through the integers list {
    if(integer is even)
        sumEven+=integer;
    else
        sumOdd+=integer;
}
Jump to Post

All 2 Replies

sumEven=0;
sumOdd=0;

loop through the integers list {
    if(integer is even)
        sumEven+=integer;
    else
        sumOdd+=integer;
}

Of course, you will need to be able to determine if the integer is even or odd. Can some mathematical operation (add, subtract, multiply or divide) be done on the integer to determine if it is even or odd? (The answer of course is yes : )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.