![]() |
In C, a 2D Array is a type of multidimensional array in which data is stored in tabular form (rows and columns). It has two dimensions so it can store the data in two directions i.e. rows and columns. In this article, we will learn how to initialize a 2D array in C. Initialize Two Dimensional Array in CWe can simply initialize a 2D array at the time of declaration by providing the values in curly braces {} using the below syntax: Syntax to Initialize 2D Array in CdataType arrayName[row size][column size]={ For runtime initialization, we need to use loops to assign values. C Program to Initialize a 2D ArrayThe below program demonstrates the initialization of a 2D array in C. C
Output
printing arr 1 1 2 3 4 5 6 7 8 9 10 11 12 printing arr 2 0 0 0 0 0 0 0 0 0 |
Reffered: https://www.geeksforgeeks.org
C Language |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |