Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Sunidhi Bansal
Page 80 of 81
Program to check if two given matrices are identical in C++
Given two matrix M1[r][c] and M2[r][c] with 'r' number of rows and 'c' number of columns, we have to check that the both given matrices are identical or not. If they are identical then print "Matrices are identical" else print "Matrices are not identical"Identical MatrixTwo matrices M1 and M2 are be called identical when −Number of rows and columns of both matrices are same.The values of M1[i][j] are equal to M2[i][j].Like in the given figure below both matrices m1 and m2 of 3x3 are identical −$$M1[3][3]=\begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \ 7 & ...
Read MoreProgram to check if a matrix is symmetric in C++
In linear algebra a matrix M[][] is said to be a symmetric matrix if and only if transpose of the matrix is equal to the matrix itself. A transpose of a matrix is when we flip the matrix over its diagonal, which resultant switches its row and columns indices of the matrix. Below the example of Symmetric matrix − $$\begin{bmatrix} 1 & 4 & 7 \ 4 & 5 & 6 \ 7 & 6 & 9 \ \end {bmatrix} \Rightarrow \begin{bmatrix} 1 & 4 & 7 \ 4 & 5 & 6 \ 7 & 6 & ...
Read MoreProgram to check if a matrix is Binary matrix or not in C++
A binary matrix is a matrix whose all elements are binary values i.e., 0 or 1. Binary matrix can be also called Boolean matrix, Relational Matrix, Logical matrix. Given below the example $$\begin{bmatrix} 0 & 1 & 0\ 1 & 1 & 0\ 1 & 0 & 1\ \end {bmatrix}\:\:\:\:\:\:\:\:\:\begin{bmatrix}0 & 3 & 0\ 1 & 1 & 0\ 1 & 0 & 2\ \end{bmatrix}\\tiny This\:is\:a\:Binary\:Matrix\:\:\:\:\:\:\:This\:is\:not\:a\:binary\:matrix$$ In Above figure first matrix on the left is a Binary matrix, the other matrix there are some values which are not Binary(0 or 1) are highlighted in red i.e., 3 ...
Read MoreProgram for Markov matrix in C++
Given a matrix M[r][c] with 'r' number of rows and 'c' number of columns, we have to check that the given matrix is Markov matrix or not. If the input matrix is Markov matrix then print the output "It is a Markov matrix" and "it's not an Markov matrix" if it is not a Markov matrix. Markov Matrix Now, what is Markov Matrix? A matrix M is a Markov matrix if and only if its sum of each row is equal to only 1. Like in the given example below − $$\begin{bmatrix}0.2 & 0.3 & 0.5 ...
Read MoreProgram to check if matrix is upper triangular in C++
Given a square matrix M[r][c] where 'r' is some number of rows and 'c' are columns such that r = c, we have to check that 'M' is upper triangular matrix or not. Upper Triangular Matrix Upper triangular matrix is a matrix in which the elements above the main diagonal(including the main diagonal) are not zero and below elements are zero only. Like in the given Example below − In above figure the red highlighted elements are lower elements from the main diagonal which are zero and rest elements are non-zero. Example ...
Read MoreProgram to check if matrix is lower triangular in C++
Given a square matrix M[r][c] where 'r' is some number of rows and 'c' are columns such that r = c, we have to check that 'M' is lower triangular matrix or not. Lower Triangular Matrix − Lower triangular matrix is a matrix in which the elements below the main diagonal(including the main diagonal) are not zero and above elements are zero only. Like in the given Example below − In above figure the red highlighted elements are upper elements from the main diagonal which are zero and rest elements are non-zero. Example ...
Read MoreProgram to check Involutory Matrix in C++
Given a matrix M[r][c], 'r' denotes number of rows and 'c' denotes number of columns such that r = c forming a square matrix. We have to check whether the given square matrix is an Involutory matrix or not. Involutory Matrix A matrix is called Involutory matrix if and only if, when a matrix gets multiplied with itself and its result is an identity matrix. A matrix I is Identity matrix if and only if its main diagonal is one and other elements than the main diagonal are zero. So, we can say a matrix is Involutory matrix ...
Read MoreProgram to check idempotent matrix in C++
Given a matrix M[r][c], 'r' denotes number of rows and 'c' denotes number of columns such that r = c forming a square matrix. We have to check whether the given square matrix is an Idempotent matrix or not. Idempotent Matrix A matrix 'M' is called Idempotent matrix if and only the matrix 'M' multiplied by itself returns the same matrix 'M' i.e. M * M = M. Like in the given example below − We can say that the above matrix is multiplied by itself and returns the same matrix; hence the matrix ...
Read MoreProgram to check diagonal matrix and scalar matrix in C++
Given a matrix M[r][c], 'r' denotes number of rows and 'c' denotes number of columns such that r = c forming a square matrix. We have to find whether the given square matrix is diagonal and scalar matrix or not, if it is diagonal and scalar matrix then print yes in the result. Diagonal matrix A square matrix m[][] will be diagonal matrix if and only if the elements of the except the main diagonal are zero. Like in the given figure below − Here, the elements in the red are main diagonal which ...
Read MoreProgram to calculate value of nCr in C++
Given with n C r, where C represents combination, n represents total numbers and r represents selection from the set, the task is to calculate the value of nCr. Combination is the selection of data from the given in a without the concern of arrangement. Permutation and combination differs in the sense that permutation is the process of arranging whereas combination is the process of selection of elements from the given set. Formula for permutation is -: nPr = (n!)/(r!*(n-r)!) Example Input-: n=12 r=4 Output-: value of 12c4 is :495 Algorithm Start Step 1 -> Declare function for calculating factorial ...
Read More