m(row) and n(coloumns) are taken from user.. Elements are taken from user.. matrix is displayed in tabular form..
This should be your first program for Matrix.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int a[10][10],m,n,i,j;
- cout<<"Enter number of rows: ";
- cin>>m;
- cout<<"Enter number of coloumns: ";
- cin>>n;
- cout<<endl<<"Enter elements of matrix: "<<endl;
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- for(i=0;i<m;i++)
- {
- for(j=0;j<n;j++)
- {
- cout<<"Enter element a"<<i+1<<j+1<<": ";
- cin>>a[i][j];
- }
- }
- cout<<endl<<"Displaying Matrix: "<<endl<<endl;
- for(i=0;i<m;i++)
- {
- for(j=0;j<n;j++)
- {
- cout<<a[i][j]<<" ";
- }
- cout<<endl<<endl;
- }
- getch();
- }
0 comments:
Post a Comment