Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1) Write two functions that square the elements in an integer array of a given size. One of the functions returns the squared value of
Q1) Write two functions that square the elements in an integer array of a given size. One of the functions returns the squared value of a single element every time it is called, and the other function operates on a pointer (there is no returned value). Now, write a third function that takes in an int pointer (will point to an int array) and an int for the size of the array. This third function will square all the elements in the given array when it is called. You must write your own libsquare.h that contains the prototypes of the three aforementioned square functions, and libsquare.c that contains the function definitions. The main source C file is given to you in a file named val ref.c to test your functions, do not change anything in this file. The following prototypes must be included in libsquare.h: int square val (int element); void square ref (int * element); void square arr(int * array, int size); The output of your code should appear as follows Enter the arraySize Enter 5 integers: 1 3 5 2 4 Array1 squared bv value: 1 9 25 4 16 Array2 squared by reference: 1 9 25 4 16 Array3 squared by array pointer: 1 9 25 4 16 To compile your code, remember that you must compile both val ref.c and libsquare.c but not libsquare.h. In other words, run 'gcc val ref.c libsquare.c' ry. You only need to submit your libsquare.c and Note: Do not use the math.h libra libsquare.h files in your tar
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started