1. Engineering
  2. Computer Science
  3. can you help me trace this three problems...

Question: can you help me trace this three problems...

Question details

12 Suppose the method int sign(int x) returns 1 if x is positive, -1 if x is negative, and 0 if x is 0. Given intIl nums 2, -1, 0, 1, 2) what are the values f the elements of nums afer the following code i etecuted? for (int k 0 k <nums.length; k++) nums [k] sign (nums [k]); nums [k] += sign (nums [k] ) ; (B) -1, 0, 0, 0, 1 (C) 0, 0, 0, 0, 0 (D) -2, 0, 0, 2,3 (E) -2, 0, 0, 0, 2

public void reverse (string i) words) inti- 0, words.length -1 while (i <j) string temp words [i]: words [i] - words [jl; words [j] temp i++i

intl] a new int[100]; int[] temp new int[a.length2] for (inti 0 i<a.length; i++) temp[i]a[il; a = temp; // reassign a to the new array; the old array is discarded

Can you help me trace this three problems?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution