Question: Question 1 The following function is supposed to return true if any element of the array a has the value 0 and false if all
Question 1 The following function is supposed to return true if any element of the array a has the value 0 and false if all elements are non-zeros. Sadly, it contains an error. Find the errors and show how to fix it. bool has_zero (int a[], int n) { int i; for (i = 0; i < n; i++) if(a[i] == 0) return true; else return false; Question 2 The following function finds the median of three numbers. Rewrite the function so that it has just one return statement. double median (double x, double y, double z) { if (x <= y) if (y <= z) return y; else if (x <= z) return z; else return x; if (z <= y) return y; if (x <= z) return x; return z; }
Question 3 Show the output produced by each of the following programs. (a) #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
