Questions by craig78 - Page 7

1. Explain the pass by value and pass by reference mechanisms. Give examples that show their difference.2. Consider the function -int f(int n, int a[]) {Int cnt = 0;for (int i=0; iif (a[i] == a[0]) cnt++;}return cnt;}Explain what it does in one sentence. What is the return value when n = 5 and a = {1, 2, 1, 2, 1}?3. Implement the makeStrCopy function. Remember that, It takes a string in copies to an output string out. The signature should be void makeStrCopy(char in[], char out[]). For example - if in = "hello", after calling makeStrCopy, out should also be "hello"4. Dynamically allocate an array of floats with 100 elements. How much memory does it take?5. Suppose int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}. Suppose the address of a[0] is at 6000. Find the value of the following -a. a[8]b. &a[5]c. ad. a+4e. *(a+2)f. &*(a+4)6. Ash tries to implement bubble sort the following way. In particular, notice that the loop iterates on the array in reverse. Fill in the box to implement the function.void sort(int n, int a[]) {for (int steps=0; stepsfor (int i=n-1; i>0; i--) {///Write code here}}}7. implement the is_reverese_sorted() function to check if an array reverse sorted. For example if a = {6, 4, 3, 1}. Then is_reverse_sorted should return True8. Modify the Selection sort function so that it sorts the array in reverse sorted order, ie. from the largest to smallest. For example reverse sorting a = {3, 4, 2, 5, 1} should result in {5, 4, 3, 2, 1}. Use the is_reverse_sorted() function to break early from the function if the array is already sorted9. We wrote a program to find all positions of a character in a string with the strchr function. Now do the same without using strchr10. Is there any difference in output if you call strstr(text, "a") and strchr(text, a)? Explain with examples.