1. Below a function my_arrfn is defined. Show the contents of the array anarr after each call to my_arrfn with the given array
    void my_arrfn(int myarr[], int sz, int m){
       int i;
         myarr[i] *= m;
} }
         a)int anarr[4] = { ­3, 4, 2, ­5};
             my_arrfn(anarr, 4, 3);
          b)int anarr[4] = {5, 2, ­2, 10};
             my_arrfn(anarr, 4, 10);

2 . Write a function called “closest” (prototype given below) which takes 3 arguments: An array of integers (arr), the size of the array (sz), and an integer (q), and returns the index of the element in arr which is closest to q.
int closest(int arr[], int sz, int q)
For instance, if arr = [1,2,5,­1], then closest(arr,4,6) should return 2 since arr[2] is closest to 6. The distances should be measured using the absolute value.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.


a) after the
int anarr[4] = { 3, 4, 2, 5};
my_arrfn(anarr, 4, 3);
is called
anarr = {9, 12, 6, 15}

b) after the
int anarr[4] = {5, 2, 2, 10};
my_arrfn(anarr, 4, 10);
is called
anarr = {50, 20, 20, 100}

The new value of the array member is the old value multiplied with m, which is 3 in a) and 10 in b) case....
$5.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats