DO NOT MISS

Ads

Thursday, 17 November 2016

Two Dimensional Array in C-Language



Multi dimensional Arrays :-

Collection of values with similar datatype using more than one subscription is known as a Multi dimensional Array.



'C' allows us to define tables of items by using two dimensional arrays.

Collection of values with similar datatype using two subscripts.It is also called table (or) Matrix.

Two dimensional arrays are declared as fallows

Syntax:-
data type array name[row size][column size];
int a[3][4];

We can create two types of rows & columns formats.

Format 1:-
Ex:- int a[3][4]
Format 2:-
Ex:- int a[3][4]

Assigning the values to 2D :-

We can Assign the values to 2D in two ways.
Those are



1. Static time

2. Dynamic time



1. Static time :-
In static time also we can assign the values in two ways.

1. 2D initialization
2. 2D assignment

1. 2D initialization :-
Assigning the values to 2D at the time 2D declaration.

Ex 1:-
int a[2][3]={{1,2,3},{4,5,6}};


Ex 2:-

int a[3][3]={{1,2,3},{4,5,6},{7,8,9}};


2. 2D assignment :-

Assigning the values to 2D after the variable declaration.



Ex:-

int a[2][3];

a[0][0]=1;
a[0][1]=2;
a[0][2]=3;
a[1][0]=4;
a[1][1]=5;
a[1][2]=6;
      
 
________________________________________
_______________________________________________________________________________



Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims