Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pls write the correct code to insert into this code QUESTION 1 100 points Save Answer In the following program, the code for function OddEvenDiff

Pls write the correct code to insert into this code image text in transcribed
image text in transcribed
QUESTION 1 100 points Save Answer In the following program, the code for function OddEvenDiff is missing. This function should return the absolute difference of the sums of odd numbers and even numbers in the vector v passed as the parameter. Examples: Input: v=[1,2,3,4,5) Output: 6 Explanation: the sum of odd numbers is 1+3+5=9. the sum of even numbers is 2+4. the difference is 9-4.5 Input: [2] Output: 2 Explanation: the sum of even numbers is 2=2. there is no odd number, so the sum of odd numbers is 0. the difference is 2-0=2 Implement the function on your computer and put your solution inside the function. Please note that you are allowed to use the sorting function to solve this problem (you will get 0 point). Also, you are not allowed to modify any other parts of the program. Submit the following: 1. The code insidde OddEvenDiff function. (60%) 2. The absolute difference of the sum of odd numbers and event numbers the list passed by the main. This is the output of your program. (40%) #include #include using namespace std; int OddEvenDiff (const vector int>& v) 1/ Put your code here } int main() { int i; const int n=1024*16; vector int> V; srand (2021); for (i=0;i<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions