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

Great Lakes PGPM & PGDM 2025
Apply
Admissions Open | Globally Recognized by AACSB (US) & AMBA (UK) | 17.3 LPA Avg. CTC for PGPM 2024 | Extended Application Deadline: 10th Jan 2024
ISBR Business School PGDM Adm...
Apply
250+ Companies | Highest CTC 16 LPA | Average CTC 8 LPA | Ranked as Platinum Institute by AICTE for 6 years in a row | Awarded Best Business School...
KR Mangalam University MBA Ad...
Apply
6 Lakh+ CUET Registrations | 500+ Companies Visited for Placement Top Recruiters: Apple Inc., Amazon, IBM, CISCO, Meta, Microsoft, Google
Asia Pacific Institute of Man...
Apply
8.11 LPA-Average Package | 1200+ Recruiters
UPES MBA Admissions 2025
Apply
Ranked #41 amongst institutions in Management by NIRF | 100% Placement | Last Date to Apply: 21st Jan
Chandigarh University Admissi...
Apply
Ranked #1 Among all Private Indian Universities in QS Asia Rankings 2025 | Scholarships worth 210 CR
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