Program to find Transpose of Matrix in C++

Here is the Program to find Transpose of Matrix in C++



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.




Addition of two matrix in C++

How It Works:

    • For 2D array size there must be constant value in square brackets like 

  • 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 in square brackets they must initialized else error will be found.
  • 3 nested for loops are used two for taking input in matrix 2D arrays and one for resultant matrix.

Here is the program for addition of two matrix in C++


Program to find Maximum and Minimum element in Array C++

Today we will a program to find the maximum and minimum element in array c++, let’s start how it works

How it Works:

  • Declare array of size 10
  • Using for loop assign array indexes with random values between 1 and 1000.
  • Call the function and pass array and its size as argument.
  • Function declares two integers max and min and assign both integers with arrays first index value.
  • Then with in for loop there are two if condition first check is for minimum number and second check is for maximum number.
  • Finally program display the output values of both integers min and max.

Following is the program to find maximum and minimum element in array:




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 “Display Array” displays the array values using for loop.
  • To manage the menu option do while is used and few if else statement within the loop to call a specific function on user selection.
  • To restrict user to enter valid option recursion is used in two functions so if user enter invalid option For example array size is 10 and user select index number 11 then a message will be displayed function will call itself and user has to enter the option again.

Follow is the Program to Insert Update and Delete elements in Array in C++


Sample Output:


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.