Arrays - 2D Array/Matrix | ||||||||||||||||||||||||||||||
Two-dimensional arrays are a little more complicated to use than one-dimensional ones. Here data is stored in the form of ROWS and COLUMNS which are accessed with the help of SUBSCRIPT number.
The following table illustrates how the subscripts are specified for this array, which has five (5) rows and four (4) columns.
| ||||||||||||||||||||||||||||||
C Language Code: | ||||||||||||||||||||||||||||||
MULTIARR.H | ||||||||||||||||||||||||||||||
// DSTC ------- MULTIARR.H #include "assert.h" typedef struct MultiDimentionArray matrix *makemat(int nr,int nc) void inputmat(matrix *m,int val, int r, int c) int inputmat(matrix *m, int r, int c) void printmat(matrix *m)
for(j=0;j < m->maxc ; j++) void subtract2mat(matrix *m1,matrix *m2,matrix *res) // precondion for matrix Multiplication is matrix *multiplymat(matrix *m1, matrix *m2) for(i=0;i < r->maxr;i++) | ||||||||||||||||||||||||||||||
MULTIARR.CPP | ||||||||||||||||||||||||||||||
// DSTC ------- MULTIARR.CPP (including MULTIARR.H header file) #include <stdio.h> main() int i,j,v ,r,c; printf("\n Enter the 1 Matrix's Dimentions r,c"); m = makemat(r,c); printf("\n Enter the 2 Matrix's Dimentions r,c"); Get Paid by Reading Ads on your Mobiles res = makemat(r,c) ; printf(" = \n" ); |
We are trying to contribute to the net what ever Technical knowledge. I Believe that knowledge increases by spreading and sharing with others.
Tuesday, January 30, 2024
Arrays - 2D Array/Matrix - DSTC using C Language (Source Code Implemented)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment