SlideShare a Scribd company logo
1 of 11
Download to read offline
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

Abstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesAbstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesPhilip Schwarz
 
C tech questions
C tech questionsC tech questions
C tech questionsvijay00791
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2vikram mahendra
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingSaurabh Singh
 
Function recap
Function recapFunction recap
Function recapalish sha
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CSAAKASH KUMAR
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CSAAKASH KUMAR
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskellLuca Molteni
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellMichel Rijnders
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskellfaradjpour
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its functionFrankie Jones
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 

What's hot (20)

Abstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesAbstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded Types
 
C tech questions
C tech questionsC tech questions
C tech questions
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
Function recap
Function recapFunction recap
Function recap
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskell
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskell
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its function
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 

Viewers also liked

Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)EngineerBabu
 
Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentationNeveen Reda
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array PointerTareq Hasan
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
Cisco Industry template - 4x3 dark
Cisco Industry template - 4x3 darkCisco Industry template - 4x3 dark
Cisco Industry template - 4x3 darkKVEDesign
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismEduardo Bergavera
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)akmalfahmi
 

Viewers also liked (20)

Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Array in c++
Array in c++Array in c++
Array in c++
 
Arrays
ArraysArrays
Arrays
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
C++ programming (Array)
C++ programming (Array)C++ programming (Array)
C++ programming (Array)
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Array in C
Array in CArray in C
Array in C
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentation
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
functions of C++
functions of C++functions of C++
functions of C++
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Cisco Industry template - 4x3 dark
Cisco Industry template - 4x3 darkCisco Industry template - 4x3 dark
Cisco Industry template - 4x3 dark
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and Polymorphism
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)
 

Similar to C++ ARRAY WITH EXAMPLES

Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Kanis Fatema Shanta
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2Mouna Guru
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxssuser3cbb4c
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)Arun Umrao
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for SpeedYung-Yu Chen
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 

Similar to C++ ARRAY WITH EXAMPLES (20)

C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
2D array
2D array2D array
2D array
 
Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]
 
Computer Programming- Lecture 9
Computer Programming- Lecture 9Computer Programming- Lecture 9
Computer Programming- Lecture 9
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
Arrays
ArraysArrays
Arrays
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
2 d matrices
2 d matrices2 d matrices
2 d matrices
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 

More from Farhan Ab Rahman (12)

C++ TUTORIAL 10
C++ TUTORIAL 10C++ TUTORIAL 10
C++ TUTORIAL 10
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
C++ TUTORIAL 6
C++ TUTORIAL 6C++ TUTORIAL 6
C++ TUTORIAL 6
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
VIBRATIONS AND WAVES TUTORIAL#2
VIBRATIONS AND WAVES TUTORIAL#2VIBRATIONS AND WAVES TUTORIAL#2
VIBRATIONS AND WAVES TUTORIAL#2
 
Notis Surau
Notis SurauNotis Surau
Notis Surau
 
Kitab Bakurah.amani
Kitab Bakurah.amaniKitab Bakurah.amani
Kitab Bakurah.amani
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

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