Question: urgentt c programming (c) Our task is to develop a function for computing the absolute value of each of the elements in a 1- dimensional
urgentt c programming
(c) Our task is to develop a function for computing the absolute value of each of the elements in a 1- dimensional array of int values. For example, for the array {1, -6, 2, -1}, the desired result is {1, 6, 2, 1}. We explore two different design patterns.
(i) Suppose that the design is to modify the argument array to reflect the result. The code below is a solution to this problem, with five snippets of code missing (named ONE, TWO, THREE, FOUR and FIVE). Your task is to fill in the necessary code in the space provided needed to complete this function. absolute( , ) { for (int i=0; i < N; i++) { if (x[i] < 0) ; } ; }
(ii) Modify the function in part (i) such that this second design can insert the new values into a new array (y) that reflects the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
