C – Passing Array to Function1 min read

Passing an array to function in the one-Dimensional array is done through an actual parameter and array variables with subscript are passed as formal arguments. While passing array only the name of the array is passed to the function.

Same method is applied for the multi-dimensional array.

There are three methods that can be used to pass an array to a function.

First Way: As a unsized array

Second Way: As a sized array

Third Way: As a pointer


Example: Passing a One-Dimensional Array in Function in C

To find the average of given number.

Output:


Example: Passing a Multi-Dimensional Array in Function in C

Program takes an input from the user and a function is used to display the array.

Output:


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More