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

ICFAI Business School-IBSAT 2024
Apply
9 IBS Campuses | Scholarships Worth Rs 10 CR
GIBS Business School Bangalor...
Apply
100% Placements with 220+ Companies
Great Lakes PGPM & PGDM 2025
Apply
Admissions Open | Globally Recognized by AACSB (US) & AMBA (UK) | 17.3 LPA Avg. CTC for PGPM 2024
SPJIMR Mumbai PGDM Admissions...
Apply
Ranked No. 1 Business School in India and no.35 in world by Financial Times MiM 2024 Ranking | Highest CTC: INR 81 LPA
XAT- Xavier Aptitude Test 2025
Apply
75+ years of legacy | Score accepted by 160+ BSchools | Apply now
GMAT™ Exam
Apply
Select test center appointment | Scores valid for 5 Years | Multiple Attempts | Round 1 Applications Closing Soon
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