SlideShare a Scribd company logo
2
Most read
5
Most read
8
Most read
C++ : ARRAY WITH EXAMPLES 
SUMMATION OF TWO MATRIXES 
#include <iostream> 
using namespace std; 
int main() 
{ 
int m,n,c,d, first[10][10], second[10][10], sum[10][10]; 
cout << "Enter the number of rows and columns of matrix" << endl; 
cin >> m>> n; 
cout << "Enter the elements of first matrix n"; 
for( c=0; c<m ; c++) 
for(d=0; d<n ; d++) 
cin >> first [c][d]; 
cout << "Enter the elements of second matrix n"; 
for(c=0; c<m; c++) 
for(d=0; d<n; d++) 
cin >> second[c][d]; 
for (c=0;c<m;c++) 
for(d=0;d<n;d++) 
sum[c][d]= first[c][d] + second[c][d];
cout << "The summation of entered matrixes :- n"; 
for(c=0; c<m; c++) 
{ 
for(d=0; d<n; d++) 
cout << sum[c][d] << "t"; 
cout << endl; 
} 
return 0; 
} 
//Output : 
Enter the number of rows and columns of matrix 
3 3 
Enter the elements of first matrix 
1 2 3 
4 5 6 
7 8 9 
Enter the elements of second matrix 
1 2 3 
4 5 6 
7 8 9 
The summation of entered matrixes :- 
2 4 6 
8 10 12 
14 16 18
DIFFERENCE OF TWO MATRIXES 
#include <iostream> 
using namespace std; 
int main() 
{ 
int m,n,c,d, first[10][10], second[10][10], sum[10][10]; 
cout << "Enter the number of rows and columns of matrix" << endl; 
cin >> m>> n; 
cout << "Enter the elements of first matrix n"; 
for( c=0; c<m ; c++) 
for(d=0; d<n ; d++) 
cin >> first [c][d]; 
cout << "Enter the elements of second matrix n"; 
for(c=0; c<m; c++) 
for(d=0; d<n; d++) 
cin >> second[c][d]; 
for (c=0;c<m;c++) 
for(d=0;d<n;d++) 
sum[c][d]= first[c][d] - second[c][d]; 
cout << "The summation of entered matrixes :- n"; 
for(c=0; c<m; c++) 
{
for(d=0; d<n; d++) 
cout << sum[c][d] << "t"; 
cout << endl; 
} 
return 0; 
} 
//Output: 
Enter the number of rows and columns of matrix 
3 3 
Enter the elements of first matrix 
7 8 9 
4 5 6 
1 2 3 
Enter the elements of second matrix 
1 2 3 
4 5 6 
7 8 9 
The summation of entered matrixes :- 
6 6 6 
0 0 0 
-6 -6 -6
TRANSPOSE OF A MATRIX 
#include <iostream> 
using namespace std; 
int main() 
{ 
int c,d, matrix[3][3],transpose_matrix[3][3]; 
cout <<"Enter the elements of 3x3 matrix n"; 
for( c=0; c<3 ; c++) 
for(d=0; d<3 ; d++) 
cin >> matrix [c][d]; 
for (c=0;c<3;c++) 
for(d=0;d<3;d++) 
transpose_matrix[c][d]= matrix[d][c]; 
cout << "The transpose of the given 3x3 matrix :- n"; 
for(c=0; c<3; c++) 
{ 
for(d=0; d<3; d++) 
cout << transpose_matrix[c][d] << "t"; 
cout << endl; 
} 
return 0; 
}
//Output: 
Enter the elements of 3x3 matrix 
1 2 3 
4 5 6 
7 8 9 
The transpose of the given 3x3 matrix :- 
1 4 7 
2 5 8 
3 6 9 
// Alternative way to find transpose of a matrix: 
#include <iostream> 
using namespace std; 
int main() 
{ 
int m,n,c,d, matrix[10][10],transpose_matrix[10][10]; 
cout << "Enter the number of rows and columns of matrix" << endl; 
cin >> m>> n; 
cout << "Enter the elements of matrix n"; 
for( c=0; c<m ; c++) 
for(d=0; d<n ; d++) 
cin >> matrix [c][d]; 
for (c=0;c<m;c++) 
for(d=0;d<n;d++)
transpose_matrix[c][d]= matrix[d][c]; 
cout << "The transpose of the entered matrixes :- n"; 
for(c=0; c<m; c++) 
{ 
for(d=0; d<n; d++) 
cout << transpose_matrix[c][d] << "t"; 
cout << endl; 
} 
return 0; 
} 
// Output: 
Enter the number of rows and columns of matrix 
5 5 
Enter the elements of matrix 
1 2 3 4 5 
6 7 8 9 10 
11 12 13 14 15 
16 17 18 19 20 
21 22 23 24 25 
The transpose of the entered matrixes :- 
1 6 11 16 21 
2 7 12 17 22 
3 8 13 18 23 
4 9 14 19 24 
5 10 15 20 25
MULTIPLICATION OF TWO MATRIXES (2X2 DIMENSION ONLY) 
#include <iostream> 
using namespace std; 
int main() 
{ 
int m,n,c,d, first[2][2], second[2][2], mult[2][2]; 
cout << "Enter the number of rows and columns of matrix" << endl; 
cin >> m>> n; 
cout << "Enter the elements of first matrix n"; 
for( c=0; c<m ; c++) 
for(d=0; d<n ; d++) 
cin >> first [c][d]; 
cout << "Enter the elements of second matrix n"; 
for(c=0; c<m; c++) 
for(d=0; d<n; d++) 
cin >> second[c][d]; 
for (c=0;c<m;c++) 
for(d=0;d<n;d++) 
mult[c][d]= first[c][0] * second[0][d] + first[c][1] * second[1][d]; 
cout << "Multiplication of entered matrixes :- n";
for(c=0; c<m; c++) 
{ 
for(d=0; d<n; d++) 
cout << mult[c][d] << "t"; 
cout << endl; 
} 
return 0; 
} 
//Output : 
Enter the number of rows and columns of matrix 
2 2 
Enter the elements of first matrix 
1 2 
3 4 
Enter the elements of second matrix 
1 2 
3 4 
Multiplication of entered matrixes :- 
7 10 
15 22
INVERSE OF A MATRIX (2x2 DIMENSION ONLY) 
#include <iostream> 
using namespace std; 
int main() 
{ 
int c,d, determinant, matrix[2][2], inv[2][2]; 
cout << "Enter the elements of 2x2 matrix n"; 
for( c=0; c<2 ; c++) 
for(d=0; d<2 ; d++) 
cin >> matrix [c][d]; 
determinant= matrix[0][0] * matrix[1][1] - matrix[0][1]*matrix[1][0]; 
for (c=0; c<2; c++) 
for(d=0; d<2; d++) 
{ if ( c==0 && d==0) 
inv[c][d]= matrix[1][1]; 
else if (c==1 && d==1) 
inv[c][d]= matrix[0][0]; 
else 
inv[c][d]= - matrix[c][d]; 
}
cout << "Inverse of entered matrixes :- n"; 
for(c=0; c<2; c++) 
{ 
for(d=0; d<2; d++) 
cout << (float) inv[c][d]/determinant << "t"; 
cout << endl; 
} 
return 0; 
} 
//Output: 
Enter the elements of 2x2 matrix 
1 2 
3 4 
Inverse of entered matrixes :- 
-2 1 
1.5 -0.5

More Related Content

What's hot (20)

PPSX
C Programming : Arrays
Gagan Deep
 
PPTX
Arrays
Trupti Agrawal
 
PPT
5.1 mining data streams
Krish_ver2
 
PPTX
Lecture 2 data structures and algorithms
Aakash deep Singhal
 
PPTX
Structure in C
Kamal Acharya
 
PPTX
Xml dtd
sana mateen
 
PPT
Multidimensional array in C
Smit Parikh
 
PPTX
Print input-presentation
Martin McBride
 
PPTX
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
PPTX
POINTERS IN C
Neel Mungra
 
PPT
Cs8092 computer graphics and multimedia unit 2
SIMONTHOMAS S
 
PPSX
Stacks Implementation and Examples
greatqadirgee4u
 
PPTX
software project management Artifact set(spm)
REHMAT ULLAH
 
PPT
Queue implementation
Rajendran
 
PPTX
Data Integration and Transformation in Data mining
kavitha muneeshwaran
 
PPTX
Relational model
Dabbal Singh Mahara
 
PPTX
sum of subset problem using Backtracking
Abhishek Singh
 
PPT
2.6 Empirical estimation models & The make-buy decision.ppt
THARUNS44
 
PPT
Tsp branch and bound
Dr.DHANALAKSHMI SENTHILKUMAR
 
PPTX
Arrays In C Language
Surbhi Yadav
 
C Programming : Arrays
Gagan Deep
 
5.1 mining data streams
Krish_ver2
 
Lecture 2 data structures and algorithms
Aakash deep Singhal
 
Structure in C
Kamal Acharya
 
Xml dtd
sana mateen
 
Multidimensional array in C
Smit Parikh
 
Print input-presentation
Martin McBride
 
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
POINTERS IN C
Neel Mungra
 
Cs8092 computer graphics and multimedia unit 2
SIMONTHOMAS S
 
Stacks Implementation and Examples
greatqadirgee4u
 
software project management Artifact set(spm)
REHMAT ULLAH
 
Queue implementation
Rajendran
 
Data Integration and Transformation in Data mining
kavitha muneeshwaran
 
Relational model
Dabbal Singh Mahara
 
sum of subset problem using Backtracking
Abhishek Singh
 
2.6 Empirical estimation models & The make-buy decision.ppt
THARUNS44
 
Tsp branch and bound
Dr.DHANALAKSHMI SENTHILKUMAR
 
Arrays In C Language
Surbhi Yadav
 

Viewers also liked (20)

PPTX
Arrays In C++
Awais Alam
 
PPTX
Array in c++
Mahesha Mano
 
PPT
Arrays
archikabhatia
 
PPTX
C++ programming (Array)
طارق بالحارث
 
PPTX
Array in c language
home
 
PPTX
Array in C
Kamal Acharya
 
PPT
Array Presentation (EngineerBaBu.com)
EngineerBabu
 
PPT
Arrays Class presentation
Neveen Reda
 
PDF
Lecture17 arrays.ppt
eShikshak
 
PPT
1 D Arrays in C++
poonam.rwalia
 
PPTX
C++ lecture 04
HNDE Labuduwa Galle
 
PPT
Unit 6 pointers
George Erfesoglou
 
PPT
02 c++ Array Pointer
Tareq Hasan
 
PPTX
functions of C++
tarandeep_kaur
 
PPTX
Concept Of C++ Data Types
k v
 
PPSX
Cisco Industry template - 4x3 dark
KVEDesign
 
PPT
Chapter 13 - Inheritance and Polymorphism
Eduardo Bergavera
 
PDF
CP Handout#2
trupti1976
 
PPT
8.3 program structure (1 hour)
akmalfahmi
 
PPTX
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
Arrays In C++
Awais Alam
 
Array in c++
Mahesha Mano
 
C++ programming (Array)
طارق بالحارث
 
Array in c language
home
 
Array in C
Kamal Acharya
 
Array Presentation (EngineerBaBu.com)
EngineerBabu
 
Arrays Class presentation
Neveen Reda
 
Lecture17 arrays.ppt
eShikshak
 
1 D Arrays in C++
poonam.rwalia
 
C++ lecture 04
HNDE Labuduwa Galle
 
Unit 6 pointers
George Erfesoglou
 
02 c++ Array Pointer
Tareq Hasan
 
functions of C++
tarandeep_kaur
 
Concept Of C++ Data Types
k v
 
Cisco Industry template - 4x3 dark
KVEDesign
 
Chapter 13 - Inheritance and Polymorphism
Eduardo Bergavera
 
CP Handout#2
trupti1976
 
8.3 program structure (1 hour)
akmalfahmi
 
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
Ad

Similar to C++ ARRAY WITH EXAMPLES (20)

PDF
C++ TUTORIAL 5
Farhan Ab Rahman
 
DOCX
2 d matrices
Himanshu Arora
 
PPTX
Two dimensional arrays
Neeru Mittal
 
PDF
Chapter13 two-dimensional-array
Deepak Singh
 
PDF
C++ Nested loops, matrix and fuctions.pdf
yamew16788
 
PDF
OOP 2012 - Hint: Dynamic allocation in c++
Allan Sun
 
PDF
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
ssuserd6b1fd
 
PDF
Introduction to cpp (c++)
Arun Umrao
 
PDF
2D array
A. S. M. Shafi
 
PPT
CBSE Class XI Programming in C++
Pranav Ghildiyal
 
PDF
C programs
Adnan Vallippadan
 
PPTX
C Programming Language Part 8
Rumman Ansari
 
DOC
Experiment 06 psiplclannguage expermient.doc
anuharshpawar22
 
DOCX
Arrays
poonamchopra7975
 
PPT
Computer Programming- Lecture 9
Dr. Md. Shohel Sayeed
 
DOCX
ماترێکس به‌ کوردی ئارام
Aram Jamal
 
PPTX
C++ Programm.pptx
Åįjâž Ali
 
PPTX
Arrays matrix 2020 ab
Dr .Ahmed Tawwab
 
PPTX
2- Dimensional Arrays
Education Front
 
PDF
#include iostream using namespace std; class Array { priva.pdf
ANSAPPARELS
 
C++ TUTORIAL 5
Farhan Ab Rahman
 
2 d matrices
Himanshu Arora
 
Two dimensional arrays
Neeru Mittal
 
Chapter13 two-dimensional-array
Deepak Singh
 
C++ Nested loops, matrix and fuctions.pdf
yamew16788
 
OOP 2012 - Hint: Dynamic allocation in c++
Allan Sun
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
ssuserd6b1fd
 
Introduction to cpp (c++)
Arun Umrao
 
2D array
A. S. M. Shafi
 
CBSE Class XI Programming in C++
Pranav Ghildiyal
 
C programs
Adnan Vallippadan
 
C Programming Language Part 8
Rumman Ansari
 
Experiment 06 psiplclannguage expermient.doc
anuharshpawar22
 
Computer Programming- Lecture 9
Dr. Md. Shohel Sayeed
 
ماترێکس به‌ کوردی ئارام
Aram Jamal
 
C++ Programm.pptx
Åįjâž Ali
 
Arrays matrix 2020 ab
Dr .Ahmed Tawwab
 
2- Dimensional Arrays
Education Front
 
#include iostream using namespace std; class Array { priva.pdf
ANSAPPARELS
 
Ad

More from Farhan Ab Rahman (12)

PDF
C++ TUTORIAL 10
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 9
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 8
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 7
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 6
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 4
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 3
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 2
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 1
Farhan Ab Rahman
 
PDF
VIBRATIONS AND WAVES TUTORIAL#2
Farhan Ab Rahman
 
PDF
Notis Surau
Farhan Ab Rahman
 
PDF
Kitab Bakurah.amani
Farhan Ab Rahman
 
C++ TUTORIAL 10
Farhan Ab Rahman
 
C++ TUTORIAL 9
Farhan Ab Rahman
 
C++ TUTORIAL 8
Farhan Ab Rahman
 
C++ TUTORIAL 7
Farhan Ab Rahman
 
C++ TUTORIAL 6
Farhan Ab Rahman
 
C++ TUTORIAL 4
Farhan Ab Rahman
 
C++ TUTORIAL 3
Farhan Ab Rahman
 
C++ TUTORIAL 2
Farhan Ab Rahman
 
C++ TUTORIAL 1
Farhan Ab Rahman
 
VIBRATIONS AND WAVES TUTORIAL#2
Farhan Ab Rahman
 
Notis Surau
Farhan Ab Rahman
 
Kitab Bakurah.amani
Farhan Ab Rahman
 

Recently uploaded (20)

PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 

C++ ARRAY WITH EXAMPLES

  • 1. C++ : ARRAY WITH EXAMPLES SUMMATION OF TWO MATRIXES #include <iostream> using namespace std; int main() { int m,n,c,d, first[10][10], second[10][10], sum[10][10]; cout << "Enter the number of rows and columns of matrix" << endl; cin >> m>> n; cout << "Enter the elements of first matrix n"; for( c=0; c<m ; c++) for(d=0; d<n ; d++) cin >> first [c][d]; cout << "Enter the elements of second matrix n"; for(c=0; c<m; c++) for(d=0; d<n; d++) cin >> second[c][d]; for (c=0;c<m;c++) for(d=0;d<n;d++) sum[c][d]= first[c][d] + second[c][d];
  • 2. cout << "The summation of entered matrixes :- n"; for(c=0; c<m; c++) { for(d=0; d<n; d++) cout << sum[c][d] << "t"; cout << endl; } return 0; } //Output : Enter the number of rows and columns of matrix 3 3 Enter the elements of first matrix 1 2 3 4 5 6 7 8 9 Enter the elements of second matrix 1 2 3 4 5 6 7 8 9 The summation of entered matrixes :- 2 4 6 8 10 12 14 16 18
  • 3. DIFFERENCE OF TWO MATRIXES #include <iostream> using namespace std; int main() { int m,n,c,d, first[10][10], second[10][10], sum[10][10]; cout << "Enter the number of rows and columns of matrix" << endl; cin >> m>> n; cout << "Enter the elements of first matrix n"; for( c=0; c<m ; c++) for(d=0; d<n ; d++) cin >> first [c][d]; cout << "Enter the elements of second matrix n"; for(c=0; c<m; c++) for(d=0; d<n; d++) cin >> second[c][d]; for (c=0;c<m;c++) for(d=0;d<n;d++) sum[c][d]= first[c][d] - second[c][d]; cout << "The summation of entered matrixes :- n"; for(c=0; c<m; c++) {
  • 4. for(d=0; d<n; d++) cout << sum[c][d] << "t"; cout << endl; } return 0; } //Output: Enter the number of rows and columns of matrix 3 3 Enter the elements of first matrix 7 8 9 4 5 6 1 2 3 Enter the elements of second matrix 1 2 3 4 5 6 7 8 9 The summation of entered matrixes :- 6 6 6 0 0 0 -6 -6 -6
  • 5. TRANSPOSE OF A MATRIX #include <iostream> using namespace std; int main() { int c,d, matrix[3][3],transpose_matrix[3][3]; cout <<"Enter the elements of 3x3 matrix n"; for( c=0; c<3 ; c++) for(d=0; d<3 ; d++) cin >> matrix [c][d]; for (c=0;c<3;c++) for(d=0;d<3;d++) transpose_matrix[c][d]= matrix[d][c]; cout << "The transpose of the given 3x3 matrix :- n"; for(c=0; c<3; c++) { for(d=0; d<3; d++) cout << transpose_matrix[c][d] << "t"; cout << endl; } return 0; }
  • 6. //Output: Enter the elements of 3x3 matrix 1 2 3 4 5 6 7 8 9 The transpose of the given 3x3 matrix :- 1 4 7 2 5 8 3 6 9 // Alternative way to find transpose of a matrix: #include <iostream> using namespace std; int main() { int m,n,c,d, matrix[10][10],transpose_matrix[10][10]; cout << "Enter the number of rows and columns of matrix" << endl; cin >> m>> n; cout << "Enter the elements of matrix n"; for( c=0; c<m ; c++) for(d=0; d<n ; d++) cin >> matrix [c][d]; for (c=0;c<m;c++) for(d=0;d<n;d++)
  • 7. transpose_matrix[c][d]= matrix[d][c]; cout << "The transpose of the entered matrixes :- n"; for(c=0; c<m; c++) { for(d=0; d<n; d++) cout << transpose_matrix[c][d] << "t"; cout << endl; } return 0; } // Output: Enter the number of rows and columns of matrix 5 5 Enter the elements of matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 The transpose of the entered matrixes :- 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25
  • 8. MULTIPLICATION OF TWO MATRIXES (2X2 DIMENSION ONLY) #include <iostream> using namespace std; int main() { int m,n,c,d, first[2][2], second[2][2], mult[2][2]; cout << "Enter the number of rows and columns of matrix" << endl; cin >> m>> n; cout << "Enter the elements of first matrix n"; for( c=0; c<m ; c++) for(d=0; d<n ; d++) cin >> first [c][d]; cout << "Enter the elements of second matrix n"; for(c=0; c<m; c++) for(d=0; d<n; d++) cin >> second[c][d]; for (c=0;c<m;c++) for(d=0;d<n;d++) mult[c][d]= first[c][0] * second[0][d] + first[c][1] * second[1][d]; cout << "Multiplication of entered matrixes :- n";
  • 9. for(c=0; c<m; c++) { for(d=0; d<n; d++) cout << mult[c][d] << "t"; cout << endl; } return 0; } //Output : Enter the number of rows and columns of matrix 2 2 Enter the elements of first matrix 1 2 3 4 Enter the elements of second matrix 1 2 3 4 Multiplication of entered matrixes :- 7 10 15 22
  • 10. INVERSE OF A MATRIX (2x2 DIMENSION ONLY) #include <iostream> using namespace std; int main() { int c,d, determinant, matrix[2][2], inv[2][2]; cout << "Enter the elements of 2x2 matrix n"; for( c=0; c<2 ; c++) for(d=0; d<2 ; d++) cin >> matrix [c][d]; determinant= matrix[0][0] * matrix[1][1] - matrix[0][1]*matrix[1][0]; for (c=0; c<2; c++) for(d=0; d<2; d++) { if ( c==0 && d==0) inv[c][d]= matrix[1][1]; else if (c==1 && d==1) inv[c][d]= matrix[0][0]; else inv[c][d]= - matrix[c][d]; }
  • 11. cout << "Inverse of entered matrixes :- n"; for(c=0; c<2; c++) { for(d=0; d<2; d++) cout << (float) inv[c][d]/determinant << "t"; cout << endl; } return 0; } //Output: Enter the elements of 2x2 matrix 1 2 3 4 Inverse of entered matrixes :- -2 1 1.5 -0.5