Q.WAP to input elements in a 2-D array and then display this
array in matrix form.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int ar[3][3],i,j,sumi=0,sumj=0;
cout<<"Enter numbers:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cin>>ar[i][j];
}
cout<<"Matrix form:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cout<<ar[i][j]<<"\t";
cout<<endl;
}
getch();
}
array in matrix form.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int ar[3][3],i,j,sumi=0,sumj=0;
cout<<"Enter numbers:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cin>>ar[i][j];
}
cout<<"Matrix form:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cout<<ar[i][j]<<"\t";
cout<<endl;
}
getch();
}
No comments:
Post a Comment