C – Two Dimensional Array1 min read

What is Two Dimensional Array in C?

Array with two subscripts is known as two dimensional Array. The 2D array is organized as the collection of rows and columns to form a matrix. 2D arrays are created to manipulate data structures.

Example: int arr[][];

Declaration of 2D array.

The following shows the syntax for declaring 2D Array.

The data-type must be a valid C data type, a unique name must be specified to each array and the arraySize must be of an integer constant. The 2D array is considered as the table with a specified number of rows and columns.

Consider the following example of 2D integer type array with 5 rows and 3 columns:

Initialization of 2D array.

2D array is initialized using the curly braces {}. Such as:

Accessing Two-Dimensional Array Elements in C

An array can be accessed by using the specific index number. It can be achieved by placing the particular index number within the bracket [][]. Such as:


Example of 2D Array in C.

Displaying the elements with index number from 2D Arrays.

Output: After executing the above code, the following result will be displayed.


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