
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

191 Views
Problem statementGiven a linked list of n positive integers. We have to find the prime number with minimum and maximum value.If the given list is −10 -> 4 -> 1 -> 12 -> 13 -> 7 -> 6 -> 2 -> 27 -> 33 then minimum prime number is 2 and maximum prime number is 13Algorithm1. Find maximum number from given number. Let us call it maxNumber 2. Generate prime numbers from 1 to maxNumber and store them in a dynamic array 3. Iterate linked list and use dynamic array to find prime number with minimum and maximum valueExample#include ... Read More

717 Views
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 & 9 \ \end{bmatrix}$$The above ... Read More

351 Views
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 and ... Read More

482 Views
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 MatrixNow, 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 \0.1 & 0.7 & 0.2 \0.4 & 0.5 ... Read More

825 Views
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 MatrixUpper 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.ExampleInput: m[3][3] = { {1, 2, 3}, {0, 5, 6}, {0, 0, ... Read More

570 Views
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.ExampleInput: m[3][3] = { {1, 0, 0}, {2, 3, 0}, {4, ... Read More

167 Views
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 MatrixA 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 if and only if ... Read More

352 Views
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 MatrixA 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 is Idempotent matrix. ExampleInput: m[3][3] = { {2, -2, -4}, ... Read More

598 Views
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 matrixA 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 are non-zero rest elements except the main diagonal are zero making it a Diagonal ... Read More

471 Views
Given with the length into centimeter as an input, the task is to convert the given length into meter and kilometreWe can use length conversion formula for this −1 m = 100 cm 1 km = 100000 cmExampleInput-: centimetre = 100 Output -: Length in meter = 3m Length in Kilometer = 0.003kmAlgroithmStart Step 1 -> Declare variables as centimetre, meter, kilometre Step 2 -> set centimetre=100 Step 3 -> Set meter = centimeter / 100.0 Step 4 -> Set kilometer = centimeter / 100000.0 Step 5 -> print meter and kilometer StopExample#include using namespace std; int main(){ float centimeter, meter, kilometer; centimeter = 300; // Converting centimeter into meter and kilometer meter = centimeter / 100.0; kilometer = centimeter / 100000.0; cout