Passing Arrays to Function in C

theteche.com
1 min readJun 1, 2021

Like the values of simple variables, it is also possible to pass the values of an array to a function. To passing arrays to function in C a one dimensional an array to a called function, it is sufficient to list the name of the array, without any subscripts, and the size of the array as arguments. for example, the call largest(a,n) will pass the whole array a to the called function. The called function expection this call must be appropriately defined. The largest function header might look like: float largest(float array[], int size) The function largest is defined to take two arguments, the array name and the size of the array to specify the number of elements in the array. The declaration of the formal argument array is made as follows: float array[]; The pair of brackets informs the compiler that the argument array is an array of numbers. It is not necessary to specify the size of the array here.

Let us consider a problem of finding the largest value in an array of elements. Passing arrays to function in C The program is as follows : Click here

--

--