Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

utograder.cse.builaro.edurcouisesENSEO Sod Q1) Write two functions that square the elements in an integer array of a given size. One of the functions returns the squared

image text in transcribed
utograder.cse.builaro.edurcouisesENSEO Sod 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 array size: Enter 5 integers: -1 3 5 2 4 Array1 squared by value: 19 25 4 16 Array2 squared by reference: 1 9 25 4 16 Array3 squared by array pointer: 19 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' Note: Do not use the math.h library. You only need to submit your libsquare.c and libsquare.h files in your tar

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions