Computer Science, asked by ManasaPullagurla, 1 month ago

Date :
PROGRAM-6
WAP to design a method called :
void sumeven(int aint b)
to take two numbers from the main()method then it will display the sum of the even numbers
as well as how many evens it found.​

Answers

Answered by rupeshvm976
1

Answer:

its depends on your input, sum is even or not

Answered by JSP2008
0

First, calculate the reverse of the given number.

  1. 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.
  2. 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