Question: 3. (30 points) The following sum function is buggy. It is intended to return the sum of all elements in an array that is
3. (30 points) The following sum function is buggy. It is intended to return the sum of all elements in an array that is passed as an argument. (1) Find the error, (2) describe why it is incorrect, and (3) suggest how to correct it. The sizeof operator returns the size of its operand. int sum(int *arr) { int i; int sum = 0%; for (i = 0%3 i < sizeof(arr); i++) { } sum += *(arr + i)%;B return sum; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
