7.1.2.Two Dimensional Array

When you want to stored many values in a variable as a table, Two Dimensional Array will help you.
Example 1:

#include<iostream.h>
#include<conio.h>
void main()
{
	int row, col;
	int matrix[10][20];
	cout<<"Enter Row : ";    cin>>row;
	cout<<"Enter Col : ";    cin>>col;
	for(int i=0;i<row;i++)
	{
		for(int j=0;j<col;j++)
		{
			cout<<"Enter Matrix["<<i<<"]["<<j<<"]: ";    cin>>matrix[i][j];
		}
		cout<<endl;
	}
	for(int i=0;i<row;i++)
	{
	        for(int j=0;j<col;j++)
			cout<<"Matrix["<<i<<"]["<<j<<"]: "<<matrix[i][j]<<endl;
	        cout<<endl;
        }
        getch();
}
Suggest Edit