WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: 11/16/13

Search This Blog

Saturday, 16 November 2013

MATRIX

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream.h>
#include<conio.h>
class matrix
{
public:

int m[10][10];             //initializing varibles needed for operations in matrix.
int i;
int j;
int r,c;


void read()
{
cout<<"ENTER ORDER OF MATRIX\n";      //Recieve the total number of rows and columun from user.
cin>>r>>c;
cout<<"ENTER ELEMENTS\n";
for(i=0;i<r;i++)
{
cout<<"\n";
for(j=0;j<c;j++)                            //programm to insert elements to array to create the matrix according to the order specified by the user
{
cin>>m[i][j];          //store rows and columns elements in m[i][j]
}
}
cout<<"\n";
}

void display()       //function to display elements in array as matrix order.
{                                                            

cout<<r<<"x"<<c<<" MATRIX \n";
cout<<"ROW   :"<<r<<"\n";
cout<<"COLUMN:"<<c<<"\n\n";
for(i=0;i<r;i++)
{
cout<<"\n";
for(j=0;j<c;j++)
{
cout<<m[i][j]<<"\t";
}
}

}
};

void main()        //calling functions.
{
matrix s;
clrscr();
s.read();
s.display();
getch();
}