72 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

Chandigarh University Admissi...
Apply
Ranked #1 Among all Private Indian Universities in QS Asia Rankings 2025 | Scholarships worth 210 CR
Amity University Noida MBA Ad...
Apply
Amongst top 3% universities globally (QS Rankings)
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: 10th Feb 2025
FOSTIIMA Business School PGDM...
Apply
Founders- All IIMA Educated | Highest CTC 25 LPA
Asia Pacific Institute of Man...
Apply
8.11 LPA-Average Package | 1200+ Recruiters
GNIOT Institute of Management...
Apply
Highest CTC International 23.31 LPA | Highest CTC Domestic 12.5 LPA | Average CTC 7.25 LPA | Avail Merit Based Scholarships
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