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
1
Answer:
its depends on your input, sum is even or not
Answered by
0
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