Monday 24 June 2013

source code: Multidimensional [2D] Array using C++ [ the most easiest, visual friendly and user friendly as always]

#include<iostream>
using namespace std;

void display() 

{
int r,c; int ary[100][100];

cout <<"row ?\nans:"; cin>> r; cout <<endl;

cout <<"coulmn ?\nans:"; cin>> c; cout <<endl;

cout <<"put the numbers and keep pressing ENTER afterwards:\n";
for (int x=0; x<r; x++)
{
for (int y=0; y<c; y++)
cin>> ary[x][y];
}

cout <<endl;


cout <<"your matrix:\n";

for (int x=0; x<r; x++)
{
for (int y=0; y<c; y++)
{
cout<<ary[x][y] <<" ";
}
cout<<endl;
}

}

int main()

{
display();
}

1 comment: