Offers
Thanks for visiting www.technoexam.com. Stay connected with us for more latest programming updates...

You are here : Home >> Tutorials >> C

Go
Basic C Tutorial

Contents
What is C ?
History
Structure of C Program
Variables & Keywords
Constants
Data Types
Operators
Operators Precedence
Conditional Statements
if Statement
if else Statement
nested if else
switch case
Looping Statements
While loop
Do While loop
For loop
Break
Continue
Goto
Functions
Passing Value
Returning Value
Passing & Returning
Recursion
Storage Class
Array
Structure
Pointer
Union
Strings
Header File
Programs Library
Projects Library
Learn More+

Contact Us

+91-8806583119

Two Dimensional Array in C

The array which is used to represent and store data in a tabular form is called as 'two dimensional array.' Such type of array especially used to represent data in a matrix form.

The following syntax is used to represent two dimensional array.

Syntax:

<data-type> <array_nm> [row_subscript][column_subscript];

Example:

	int a[3][3];
	

In above example, a is an array of type integer which has storage size of 3 * 3 matrix. The total size would be 3 * 3 * 2 = 18 bytes.

It is also called as 'multidimensional array.'

Memory Allocation of 2 Dimensional Array

	    Two dimensional array
    Fig : Memory allocation for two dimensional array

Program :

// Program to demonstrate two dimensional array
#include <stdio.h>
#include <conio.h>
int main(void)
{
	int a[3][3], i, j;
	clrscr();
	printf("\n\t Enter matrix of 3*3 : ");
	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++)
		{
		scanf("%d",&a[i][j]);  //read 3*3 array
		}
	}
	printf("\n\t Matrix is : \n");
	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++)
		{
		printf("\t %d",a[i][j]);  //print 3*3 array
		}
	   printf("\n");
	}
	getch();
	return 0;
}

Output :


	Enter matrix of 3*3 : 3 4 5 6 7 2 1 2 3
	
	Matrix is :
	3	4	5
	6	7	2
	1	2	3_

Limitations of two dimensional array

Download PDF
Published on: 12th Nov 2010, Last Updated on: 18th Dec 2014

Mr. Dinesh Kudache
AUTHOR: Mr. Dinesh Kudache

Mr. Dinesh is the Founder and CEO of technoexam.com. He had 6+ years experience in Application Programming, System Programming, Web Design and Development, Google Expertise. He had written 5000+ various articles on programming. Browse more articles by this author.

Link this post on your Blog/Website :