Answer the Exercises below.
Create a separate file (source code) for every exercise and name it according to the exercise number (e.g. Exercise 2-1.c). The answers to the advanced questions can be included as a separate function in the original file for the exercise it belongs to.
Zip all the files and submit it via Google Classroom.
Naming Convention for the zip file: [Last Name], [First Name] - Array and String Exercise.zip
classroom code : 6rfue3e
Remember, arrays can only be processed on a PER ELEMENT BASIS. This will be important when we discuss passing arrays as parameters to functions. When parameters are passed to functions as pass by value, you normally copy the value of the variable into the parameter, However, as stated, this cannot be done for arrays…
Therefore, in order to pass arrays as parameters, we have to pass the BASE ADDRESS of the array instead, then use POINTER DEREFERENCING to access the elements of the array. Harkening back to dynamic lists, to perform this properly, we must also pass the number of elements of the array into the function.
There is indeed an easier way to pass arrays as parameters. We can use the ARRAY INDEXING notation in parameters too! To do this, we have to declare an array parameter by using the following syntax for the parameter:
return_type function_name (array_type parameter_name, ...)
So how do we determine the size of the array parameter? Well, we have to pass it as a parameter as well:
return_type function_name (array_type parameter_name, int size, ...)