My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

input, output two dimensional array

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int x[10][10],m,n;
 cout<<"number of rows and colomns:"<<endl;
 cin>>m>>n;
 cout<<"enter the elements";
 for(int i=0;i<m;i++)

  for(int j=0;j<n;j++)//if we put braces here then int j is defined
            // in another line otherwise not
  cin>>x[i][j];

 for(i=0;i<m;i++)
 {
  for(j=0;j<n;j++)
  cout<<x[i][j]<<"\t";
  cout<<endl;
  }
  getch();
  }

0 comments: