Recent Posts

Sunday 4 February 2018

2d array in C

In the previous post we learn about what is array and what is one dimensional array.In this post we will learn what is two dimensional array.

What is Array:

  • Array is a collection of similar type of data type.
  • Array is used to store more than one values of same data type under a single variable name in a continuous memory location.

What is two dimensional Array:

  1. Two dimensional array consist of number of rows and number of columns.
  2. Each row consist of specified number of columns.
  3. For accessing element in two dimensional array we have to provide array name followed by row number and column number.
  4. If we skip the column number then specified row number and first column that is zero index value is accessed.
  5. If we skip both column and row then first row (index zero) and first column (index zero) value is accessed.

How to declare two dimensional Array:              

  1. To declaring two dimensional array we have to write data type followed by followed by array name followed by total number of rows and followed by total number of columns in each row.
  2. Row and column numbers are specified in separate square brackets ([ ]).
Syntax: Data type Array name [row][column];
Example:int num[5][5];


How to initialize two dimensional Array:

  1. We can assign the values to array elements at the time of declaration of array.
  2. Each rows values are enclosed within separate inner parenthesis and two values are separated by comma (,).
Syntax: data type arrayname [row][column]={0th row elements}
                                                                         {1st row elements}
                                                                          .....
                                                                          };
Example: int num [5][5]={{1,2,3,4,5},{2,4,6,7,8},{5,6,7,8,9,}};

   

0 comments:

Post a Comment

Followers

Popular Posts

Categories

social media

Text Widget

Powered by Blogger.

About Me

My name is junaid khan and i am a full time blogger and author of a blog tutorial called tutorialpointsolution.

String function

In the previous post we learn about what is String .we know that string is a collection of two or more characters.In string we can store al...

Search This Blog

Technology

Adbox

Recent Post

Breaking

Recent In Internet

Comments

Facebook

Pages

Comments

Pages

Recent

Pages

Technology