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

Recommended Answers

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.