71 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

ISBR Business School PGDM Adm...
Apply
180+ Companies | Highest CTC 15 LPA | Average CTC 7.5 LPA | Ranked as Platinum Institute by AICTE for 6 years in a row | Awarded Best Business Scho...
K J Somaiya Institute of Mana...
Apply
Highest CTC: INR 28.25 LPA | Average for Top 100 offers: INR 17.34 LPA | Ranked #63 in India under Management category by NIRF | 148 Recruiters
Great Lakes PGPM & PGDM 2025
Apply
Admissions Open | Globally Recognized by AACSB (US) & AMBA (UK) | 17.3 LPA Avg. CTC for PGPM 2024 | Application Deadline: 1st Dec 2024
Bharathidasan Institute of Ma...
Apply
#94 in Management Category by NIRF | AACSB Member | AICTE Approved
JIMS- Kalkaji PGDM Admissions...
Apply
60+ Students Placed at Grant Thornton (Batch 2023-25) with a Record-Breaking Salary of INR 11.5 LPA Assured placements. Highest CTC - 35 LPA. Schol...
FORE School of Management PGD...
Apply
AICTE Approved | NBA & SAQS Accredited | Ranked #53 by NIRF 2024 | Highest CTC: 70 LPA | Avg. CTC: 16.01 LPA
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