answersLogoWhite

0


Best Answer

#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 */

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

# 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();

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Matrix addition using 2-D array in turbo c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you find matrix in c?

using multidimensional array


Is it possible to print matrix without using array?

Yes but why.


C program to sort all elements of a 4x4 matrix?

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 = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


What is matrix programming in C programming?

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


How matrices can be represented using two dimensional array?

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.

Related questions

How do you find matrix in c?

using multidimensional array


Is it possible to print matrix without using array?

Yes but why.


Write a c program for matrix addition using function?

#include&lt;


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


C program to sort all elements of a 4x4 matrix?

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 = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


Write a program using iostreams to take as input two multi-dimensional arrays and print their sum as output Matrix Addition in Matrix format?

http://www.assignmentsclub.com/


What is matrix programming in C programming?

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


How matrices can be represented using two dimensional array?

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.


Queue ADT Using Array?

implement the queue ADT using an array


Why and is not using ' and ' in reading a string using scanf?

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]


Algorithm of augment matrix a of order nn 1 stored using two dimensional array of size nn 1the solution of system of linear equation is stored in one dimensional array name x of size n?

Please use the discussion area to state your question in English.


Write a program in c to find the largest no out of a matrix of order mn?

/* 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&lt;M; i++) { ... ... for (j=0; j&lt;N; j++) { ... ... ... element = array + i*M + j; ... ... ... if (*element &gt; answer) answer = *element; ... ... } ... } ... return answer; }