Write a program to add, subtract, multiply two matrices in c++ ?

Answers (1)

/* C Program to perform matrix operations ,matrix addition, matrix subtraction, matrix multiplication – addition */
#include <stdio.h>
int main()

//fill your code
int m, n;
scanf(“0 0”,&m,&n);
int i, j;
int mat1[m][n], mat2[m][n], mat3[m][n];
for(i = 0; i < m; i++)

for(j = 0; j < n; j++)
scanf(“0”,&mat1[i][j]);

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

for(j = 0; j < n; j++)
scanf(“0”,&mat2[i][j]);

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

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

mat3[i][j] = mat1[i][j] + mat2[i][j];

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

for(j = 0; j < n; j++)
printf(“0 “, mat3[i][j]);
printf(“ ”);

return 0;

Most Viewed Questions

Preparation Products

Knockout JEE Main April 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Knockout NEET Aug 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Knockout JEE Main May 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-
Buy Now
Knockout NEET Aug 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-
Buy Now
Test Series JEE Main May 2021

Unlimited Chapter Wise Tests, Unlimited Subject Wise Tests, Unlimited Full Mock Tests, Get Personalized Performance Analysis Report,.

₹ 6999/- ₹ 2999/-
Buy Now
Boost your Preparation for JEE Main with our Foundation Course
 
Exams
Articles
Questions