Showing posts with label mxn. Show all posts
Showing posts with label mxn. Show all posts
Friday, February 13, 2015
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
}
Wednesday, February 11, 2015
C program to read a matrix of size mxn and display it on the screen

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5][5],n,m,i,j;
clrscr();
printf("Enter value of m and n: ");
scanf("%d%d",&m,&n);
printf("
Enter elemets of the matrix:
");
for(i=0;i<m;++i)
for(j=0;j<n;++j)
scanf("%d",&a[i][j]);
printf("
The Matrix is:
");
for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
printf("%d ",a[i][j]);
printf("
");
}
getch();
}
Subscribe to:
Posts (Atom)