c program to pass entire array into a function

Certainly! Here is an example of a C program that passes an entire array into a function:

#include <stdio.h>

void printArray(int arr[], int size) {
    for (int i = 0; i < size; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
}

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    int size = sizeof(arr) / sizeof(arr[0]);

    printArray(arr, size);

    return 0;
}

In this program, we have a function called printArray that takes two parameters: an array arr and its size size. Inside the function, we use a for loop to iterate over each element of the array and print it.

In the main function, we declare an integer array arr with some values and calculate its size by dividing the total size of the array by the size of one element. Then, we call the printArray function and pass the array arr and its size as arguments.

When you run this program, it will print the elements of the array as output:

1 2 3 4 5

I hope this example helps! Let me know if you have any further questions.