Documente Academic
Documente Profesional
Documente Cultură
programmerdouts.blogspot.com/2019/06/two-dimensional-array-in-c.html
Multidimensional Array.
Multi-dimensional is declared as same as One-dimensional arrays,
thus required separate square brackets is require. two-
dimensional require two brackets ,three dimensional required
three brackets and so on.
Two-Dimensional Array
You can Assume a Two -dimensional array as a table which
contains rows and columns
Declaration of Two-dimensional array require two brackets
In first bracket ,you have to specified number of rows and In second
Bracket you have to specified number of columns.
As one-dimensional array, Element of two-dimensional array has
a unique index number.
1/4
#include<stdio.h>
void main()
{
int arr[3][4]; //integer type of Two-dimensional array having 3 rows and 4
columns.
#include<stdio.h>
void main()
{ //integer type of Two-dimensional array having 3 rows and 4 columns.
int arr[3][4] = {{98,65,5,87}, // first row.
{32,42,65,64}, //second row.
{31,74,47,14}}; //third row.
2/4
Accessing the elements of 2d array.
As we know each element of an array has a unique index number,
with the help of that we will access the elements.
#include<stdio.h>
void main()
{ //integer type of multi-dimensional array having 3 rows and 4 columns.
int row1_col1,row2_col2,row0_col0;
int arr[3][4] = {{98,65,5,87}, //First row
{32,42,65,64}, //second row
{31,74,47,14}}; //third row
row0_col0 = arr[0][0];
row1_col1 = arr[1][1];
row2_col2 = arr[2][2];
3/4
Output:
Element at 0th_row and 0th_col is 98
Element at 1st_row and 1st_col is 42
Element at 2nd_row and 2nd_col is 74
Further Concepts:
How to initialize Two Dimensional Array?
How to take Elements of Two dimensional array from the User?
How to display 2D Array As an Table?
Practice Program Regarding Arrays
Practice Programs
Programs regarding Arrays
Programs Regarding 2d arrays
Programs regarding matrix
And lot more
Further Topics:
4/4