Program to find Transpose of Matrix in C++

Here is the Program to find Transpose of Matrix in C++ PROGRAM: #include<iostream> using namespace std; int main() { int a[10][10],m,n,i,j; cout<<“Enter number of rows: “; cin>>m; cout<<“Enter number of coloumns: “; cin>>n; if(m!=n) { cout<<“Matrix not square so Transpose not possible :(“; } else { cout<<endl<<“Enter elements of matrix: “<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { […]

Read More

Matrix multiplication in C++

How matrix multiplication in C++ Works:   Input two matrices. Run 3 for loops (i,j,k). Multiplication will be addition of First_Matrix[i][k]*Second_Matrix[k][j] for each element. Resultant matrix is stored in third Matrix.   CODE: #include<iostream> using namespace std; int main(){ //Using const int for array size const int row=2,col=2; // if not use const error found […]

Read More

Addition of two matrix in C++

How It Works: For 2D array size there must be constant value in square brackets like  array[constant value][constant value].   Two const variables row and col are used to define size. if we do not make both const then error found because without const reserve word they are behaving as variable. Before placing both variable […]

Read More

Program to Insert Update and Delete elements in Array in C++

How it Works: This code is managing a small database in array like insert, update and delete integer values in array. Program has global array declaration of size 10. Global declaration allows it accessible inside any function. A function name “Default values” is initializing all array indexes by default value of -1. A function name […]

Read More

Program to Reverse an Array in C++

Program explanation: Program declare an integer array of size five, initialize it using for loop.  Pass size and array name to function. Function uses for loop and swap array elements with in it.  A for loop is used to display the final result. Following is the program to reverse an array. #include <iostream> using namespace […]

Read More

Sum Array challenge

In this challenge, given an array of integers, the goal is to efficiently find the subarray that has the greatest value when all of its elements are summed together. Note that because some elements of the array may be negative, the problem is not solved by simply picking the start and end elements of the […]

Read More

Different ways to pass Array into Function in C++

There are many ways in which you can pass array into function. I’ve discussed 3 different ways to do this. How programs works: 1-  Declare array of size 10 2- Initialize it using for loop 3- Calling “UpdateArray” function and passing array as argument 4- Take squares of all values and update it 5- Display […]

Read More

Program to find maximum number in array C++

Following is Code to find Maximum number in array C++ PROGRAM: #include<iostream> using namespace std; int main() { cout<<“Enter The Size Of Array: “; int size; cin>>size; int array[size], key,i; // Taking Input In Array for(int j=0;j<size;j++){ cout<<“Enter “<<j<<” Element : “; cin>>array[j]; } //Your Entered Array Is for(int a=0;a<size;a++){ cout<<“array[ “<<a<<” ] = “; […]

Read More