answersLogoWhite

0

Sum of two matrices in c program?

Updated: 12/19/2022
User Avatar

Wiki User

13y ago

Best Answer

#include<stdio.h>

#include<conio.h>

main()

{

int a[4][4],b[4][4],c[4][4],i,j;

printf("enter the elements of matrix a");

for(i=0;i<=3;i++)

for(j=0;j<=3;j++)

scanf("%d",&a[i][j]);

printf("the first matris is");

for(i=0;i<=3;i++)

{

printf("\n");

for(j=0;j<=3;j++)

printf("%d",a[i][j]);

}

printf("Enter the elements of second matrix");

for(i=0;i<=3;i++)

for(j=0;j<=3;j++)

scanf("%d",&b[i][j]);

printf("the second matrix is");

for(i=0;i<=3;i++)

{

printf("\n");

for(j=0;j<=3;j++)

printf("%d",b[i][j]);

}

for(i=0;i<=4;i++)

for(j=0;j<=4;j++)

c[i][j]=a[i][j] + b[i][j];

printf("the addition of matrix is");

for(i=0;i<=3;i++)

{

for(j=0;j<=3;j++)

printf("%d\t",c[i][j]);

printf("\n");

}

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sum of two matrices in c program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a C program to find sum of 3 matrices?

matrix


Program to display multiplication of two matrix?

The matrix multiplication in c language : c program is used to multiply matrices with two dimensional array. This program multiplies two matrices which will be entered by the user.


Is there any benefit in a C plus plus program to add two matrices?

No.


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


Write a c program using dynamic memory allocation function calloc to find sum of two matrices and also print the resultant matrix?

printf("%s",per&gt;50?:"pass",per&lt;50?:"fail");


What is algorithm to multiply two matrices?

a,b,c,d,


Addition of two matrices?

The two matrices and their answer must be of the same dimensions. Each element of the answer matrix is the sum of the elements in the corresponding elements on the matrices that are being added. In algebraic form, if A = {aij} where 1 &le; i &le; m, 1 &le; j &le; n is an mxn matrix B = {bij} where 1 &le; i &le; m, 1 &le; j &le; n is an mxn matrix and C = {cij} = A + B, then C is an mxn matrix and cij = aij + bij for all 1 &le; i &le; m, 1 &le; j &le; n


What write a program in C to print the sum of two matrices of order 32?

Here is the code snippet: int arr[32][32], arr2[32][32], ans[32][32]; for( i=0; i&lt;32; i++){ for( j=0; j&lt;32; j++) ans[i][j] = arr[i][j] + arr1[i][j]; }


Write a c program that multiplies two numbers by repeated subtraction?

int mul (int a, int b) { int sum= 0; for (; b&gt;0; --b) sum -= -a; for (; b&lt;0; ++b) sum -= a; return sum; }


Addition of two numbers on plsql program?

--THE SUM OF TWO NUMBERS: declare a number(2); b number(2); c number(2); begin a:=&amp;a; b:=&amp;b; c:=a+b; dbms_output.put_line(a ' + 'b' = 'c); end;


How do you Write a program in c language to calculate the sum of two integers?

#include #include #include void main(){char a;int firstInt, secondInt, sum;cout > firstInt >> secondInt;sum = firstInt + secondInt;cout


How do you Write a program in c to calculate the sum of two integers?

/*use "c-free" compiler*/ #include &lt;stdio.h&gt; main() { int a,b,c; printf("enter the value of a &amp; b"); scanf("%d%d",&amp;a,&amp;b); c=a+b; printf("sum of the two numbers is a+b- %d",c); getch(); }