The algorithm must find the count of even numbers present in the array. Also, the sum of values of all the even number elements must be found and printed.
Answers
Answered by
0
Simple approach: A number is said to be Even if it is completely divisible by 2. A number is said to be Odd if it is leaves 1 as remainder on dividing by 2.
Other approach: We can also check if a number is odd by doing AND of 1 and that digit, if the result comes out to be 1 then the number is odd otherwise even.
Here, we will check if a number is odd , then we will increment the odd
counter otherwise we will increment the even counter.
Similar questions