Answered step by step
Verified Expert Solution
Question
1 Approved Answer
explain briefly The function below is supposed to remove all negative numbers from an array. The function takes three parameters: list (the array of integers),
explain briefly
The function below is supposed to remove all negative numbers from an array. The function takes three parameters: list (the array of integers), length (the length of the array), and sum_ptr (a parameter written by remove_neg with the sum of all values removed from the array). The function returns the adjusted length of the array (the original length minus the number of negative numbers removed). You may assume that length is positive. Unfortunately, Prof. Lumetta has again left blanks in the code. Fill in the blanks to complete the code. Note that this problem is NOT MULTIPLE CHOICE. Write the correct code directly on the blanks to complete the function. int // blank #1 remove_neg ( int length, int* sum_ptr). { int // blank #2 int i; for (i = 0, *sum_ptr = 0; length > i; i++) { %3D if ( // blank #3 list (adj_len++] = list[i]; ) else { * sum_ptr = // blank #4 // blank #5 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started