Question :
Write a program to return the difference between the sum of odd numbers and even numbers
from an array of positive integers.
Note:
You are expected to write code in the findOddEvenDifference function only which will receive
the first parameter as the number of items in the array and second parameter as the array
itself. You are not required to take input from the console.
Example
Finding the difference between the sum of odd and even numbers from a list of 5 numbers
Input
input1:5
input2: 10 11 7 12 14
Output
-18
Explanation
The first parameter (5) is the size of the array. Next is an array of integers. The calculation of
difference between sum of ood and even numbers is as follows:
(11 - 7) - (10 - 12 - 14) - 18 - 36 *. 18
Answers
Answered by
22
Answer:
- Input
- input 1 : 5
- input 2 : 10 11 7 12 14
- Output
- -18
- Explanation
- The first paramter (5) is the szie of the array. Next is an array of integers. The calculation of difference between sum of odd and even numbers is as follows:
- (11+7) – (10+12+14) = 18 – 36 = -18
Answered by
0
Concept Introduction:-
Data which has been handled and organised and structured and it puts data into context and facilitates decision-making.
Given Information:-
We have been given that The first parameter is the size of the array. Next is an array of integers. The calculation of difference between sum of ood and even numbers is as follows:
To Find:-
We have to find that a program to return the difference between the sum of odd numbers and even numbers from an array of positive integers.
Solution:-
According to the problem
include
int findOddEvenDifference
for
{
if
{
}
else
{
}
Final Answer:-
The correct answer is the programme written in the java script.
#SPJ3
Similar questions