Friday, February 13, 2015

C program to read a matrix of size mxn from the keyboard and display the same on the screen

C++ program to read a matrix of size mxn from the keyboard and display the same on the screen

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clear the screen
int a[5][5],n,m,i,j;
cout<<"Enter value of m and n:";
cin>>m>>n;
cout<<"
Enter elemets of the matrix:
";


for(i=0;i<m;++i)
for(j=0;j<n;++j)
cin>>a[i][j];
cout<<"
The Matrix is:
";

for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
cout<<a[i][j]<<" ";
cout<<"
";

}
getch(); //to stop the screen
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.