Computer Science, asked by KoyenaKundu15, 1 month ago

WAP to design a method called: void sumeven(int a.int b)

to take two numbers from the main()method then it will display the sum of the even number as well as how many evens it found.​

Answers

Answered by JSP2008
4

First, calculate the reverse of the given number.

To the reverse number, we apply the modulus operator and extract its last digit which is actually the first digit of a number so it is an oddly positioned digit.

The next digit will be even positioned, and we can take the sum in alternating turns.

Examples:

Input: N = 54873

Output:

Sum odd = 16

Sum even = 11

Input: N = 457892

Output:

Sum odd = 20

Sum even = 15

Similar questions