#include<stdio.h>
#include<conio.h>
int main(void)
{
int a[100][100]={0}; /* initializing matrices to '0' */
int b[100][100]={0};
int c[100][100]={0}; /*matrix-c for multiplication*/
/*r1,c1 are rows and coloumns for matrix-a.r2,c2 for matrix-b.*/
int r1,c1,r2,c2;
int i,j,k;
clrscr();
printf("enter the no of ROWS and COLOUMNS for MATRIX-A\n");
scanf("%d %d",&r1,&c1);
printf("enter the no of ROWS and COLOUMNS for MATRIX-B\n");
scanf("%d %d",&r2,&c2);
if(c1==r2)
{
printf("matrix multiplication possible\n\nenter numbers in MATRIX-A\n");
/* to enter numbers in matrix-a*/
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
scanf("%d",&a[i][j]);
printf("enter numbers in MATRIX-B\n");
/* to enter numbers in matrix-b*/
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
scanf("%d",&b[i][j]);
/*for matrices multiplication*/
for(i=0;i<r1;i++)
for(j=0;j<c2;j++)
for(k=0;k<c1;k++)
*(*(c+i)+j)+=*(*(a+i)+j)*(*(*(b+k)+j));
printf("result of multiplication of matrices is \n");
/*to display as matrix format*/
for(i=0;j<r1;i++)
{
printf("\n");
for(j=0;j<c2;j++)
printf("%d\t",*(*(c+i)+j));
}
} //if
else
printf("MATRIX multiplication not Possible\n");
getch();
return 0;
}
/* TWINKLING TWINS */
# include <stdio.h>
#include <conio.h>
void main ()
{
int i,j;
int a[2][2],b[2][2],c[2][2];
printf("\nAddition of A & B martices");
printf("\n\n Enter elements of martix A = ");
for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter elements of matrix B = ");
for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}
printf("Answare");
printf("\n\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d",c[i][j]);
printf("\t");
}
printf("\n");
}
getch();
}
using multidimensional array
Yes but why.
This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &matrix[0][0]; element < &matrix[3][3]; element ++) { ... ... if (*element > *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }
C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion
You've pretty much answered your own question because a two-dimensional array is a matrix. Indeed, all multi-dimensional arrays are matrices. When we create a matrix, we generally know what type of data will be stored in the matrix, how many dimensions it will have and how many elements each dimension will have, thus an array is the ideal container to represent a matrix. It provides the most compact method of storing homogeneous data, provides efficient constant-time random access to the data and introduces the least amount of abstraction into the representation. Most languages do not provide a built-in matrix type, however this is simply because there is no one matrix type that would suit every possible application. However, all languages do provide a built-in array mechanism which can be used as the basis for any matrix type which is both simple to create and easy to maintain.
using multidimensional array
Yes but why.
#include<
write ashell script to add awo matrix using array.
This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &matrix[0][0]; element < &matrix[3][3]; element ++) { ... ... if (*element > *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }
http://www.assignmentsclub.com/
C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion
You've pretty much answered your own question because a two-dimensional array is a matrix. Indeed, all multi-dimensional arrays are matrices. When we create a matrix, we generally know what type of data will be stored in the matrix, how many dimensions it will have and how many elements each dimension will have, thus an array is the ideal container to represent a matrix. It provides the most compact method of storing homogeneous data, provides efficient constant-time random access to the data and introduces the least amount of abstraction into the representation. Most languages do not provide a built-in matrix type, however this is simply because there is no one matrix type that would suit every possible application. However, all languages do provide a built-in array mechanism which can be used as the basis for any matrix type which is both simple to create and easy to maintain.
implement the queue ADT using an array
I guess you wanted to ask, why is it scanf ("%s", array)and not scanf ("%s", &array).Well, array is by definition a pointer to the first element: array = &array[0]
Please use the discussion area to state your question in English.
/* using ellipses (...) to indicate tabs for clarity */ double largest (double *array, int M, int N) { ... int i, j; ... double *element; ... double answer = array[0][0]; ... for (i=0; i<M; i++) { ... ... for (j=0; j<N; j++) { ... ... ... element = array + i*M + j; ... ... ... if (*element > answer) answer = *element; ... ... } ... } ... return answer; }