77 Views

1.Write program toper form following operations on a two dimentional matrix (i) Addition (ii) Subtraction (iii) Multipication (iv) Transpose (v) inverse (vi) print lower diagonal of a matrix. (vii) Check if the matrix is a magic square or not


bhaskarraj252003 16th Feb, 2021
Answer (1)
Abir Gayen 18th Feb, 2021

Hi Aspirant,

The following program can be done in many languages like C,Java,C++ etc.The program for C for additin,subtraction and multiplication I am providing below:

#include <stdio.h>

int main()

{

//fill your code

int m, n;

scanf(“%d %d”,&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(“%d”,&mat1[i][j]);

}

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

{

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

scanf(“%d”,&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(“%d “, mat3[i][j]);

printf(“\n”);

}


return 0;

}

Hope it helps!!

Related Questions

Graphic Era (Deemed to be Uni...
Apply
NAAC A+ Grade | Among top 100 universities of India (NIRF 2024) | 40 crore+ scholarships distributed
JSS University Mysore BBA Adm...
Apply
NAAC A++ Accredited| Ranked #24 in University Category by NIRF
Sharda University Admissions ...
Apply
North India's Largest Educational Group | NIRF Ranked 86 | NAAC A+ Grade | Highest Package 1.6 Cr | Scholarships upto 100% | Pay Rs.500 instead of ...
Manav Rachna-MBA Admissions 2025
Apply
41000+ Alumni network | Students from over 20 countries
JSS University Noida MBA 2025
Apply
170+ Recruiters Including Samsung, Zomato, LG, Adobe and many more | Highest CTC 47 LPA
Globsyn Business School PGDM ...
Apply
Highest CTC: Rs 18.33 LPA | Average CTC: Rs 7.39 LPA | Experiential Learning | Classes by Industry Professionals | Alumni Mentorship Program
View All Application Forms

Download the Careers360 App on your Android phone

Regular exam updates, QnA, Predictors, College Applications & E-books now on your Mobile

150M+ Students
30,000+ Colleges
500+ Exams
1500+ E-books