Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

10 Mar 2013

PRINTING A MATRIX IN C++

Q.) Write a C++ Program to input the elements of  a matrix and then print them in matrix form.

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

void main()
{
   clrscr();
   int a[10][10];
   int i, j, n, m;
  
   cout<<"enter no of rows  \n";
   cin>>n;
   cout<<"enter no of colomn  \n";
   cin>>m;
   cout<<"enter the values of matrix  \n";
  
   for(i=0;i<n;i++)
     {
         for(j=0;j<m;j++)
           {
               cout<<"a["<<i+1<<"]["<<j+1<<"]:= ";
               cin>>a[i][j];
           }
     }
   cout<<"matrix u have entered is \n ";
  
   for(i=0;i<n;i++)
      {
          for(j=0;j<m;j++)
            {
                  cout<<"\t"<<a[i][j];
            }
         cout<<"\n";
     }

  getch();
}


                                        =OUTPUT=

No comments:

Post a Comment