PROGRAM TO CALCULATE MATRIX WITH DYNAMICS (FREE) ORDER USING C++ PROGRAMMING LANGUAGE

in #utopian-io7 years ago (edited)

What Will I Learn?

We will learn about how to create a program to calculate matrix with dynamics (free) order using C++ programming language

Requirements

Dev C++ 5.11

Difficulty

-Intermediate

Tutorial Contents

This program was created to help users calculate a matrix with a dynamic (free) order there are no provisions for special orders are entered into the program. for the example, you can input the order 2x3 and 2x4. for the example, you can input the order 2x3 and 2x4.

Theory
the matrix is the order of the numbers in a rectangular shape and is flanked by a cage "( ) or" brackets "[ ]". A notation on the right matrix with the letters capital. A matrix has the size of the order. The order of the matrix-shaped axb with a lot of rows and b many columns.

Brackets are used to enclose the matrix members can be either ordinary parentheses or square brackets. Each number on the matrix is called the matrix of elements (elements). A collection of elements that are pre-arranged horizontally is called rows, while the collection of elements that are pre-arranged a vertically is called the column. A matrix which has m rows and n columns is called n x m matrix and is referred to as the matrix has order m x n matrix Writing. using capital letters and bold.

code for program:


using namespace std
int main(void)
{
 int A[100][100],B[100][100],C[100][100],i,j,k,RowsA,ColumnA,RowsB,ColumnB,RowsC,ColumnC;
 cout<<"Created By:\n";
 cout<<"~Baixiian~\n";
 //Enter the order of the matrix A
 cout<<"Enter the order of the matrix A:"<<endl;
 cout<<"======================="<<endl;
 cout<<"The number of rows:";
 cin>>RowsA;
 cout<<"The number of Columns :";
 cin>>ColumnA;
 //Select the number of matrix A
 cout<<"Select the number of matrix A:"<<endl;
 cout<<"========================="<<endl;
 for(i=0;i<RowsA;i++)
 {
  for(j=0;j<ColumnA;j++)
  {
   cout<<"\nElements of "<<(i+1)<<","<<(j+1)<<":";
   cin>>A[i][j];
  }
 }
 //Print A matrix
 cout<<"\nMatrix A: \n";
 for(i=0;i<RowsA;i++)
 {
  for(j=0;j<ColumnA;j++)
  {
   cout<<setw(4)<<A[i][j];
  }
  cout<<endl;
 }
 //Enter the order of the matrix B
 cout<<"Enter the order of the matrix B:"<<endl;
 cout<<"======================="<<endl;
 cout<<"The Number of rows:";
 cin>>RowsB;
 cout<<"The number of column:";
 cin>>ColumnB;
 //Select the number of matrix B
 cout<<"Select the number of matrix B:"<<endl;
 cout<<"========================="<<endl;
 for(i=0;i<RowsB;i++)
 {
  for(j=0;j<ColumnB;j++)
  {
   cout<<"\nElements of "<<(i+1)<<","<<(j+1)<<";";
   cin>>B[i][j];
  }
 }
 //Print B matrix
 cout<<"\nMatrix B : \n";
 for(i=0;i<RowsB;i++)
 {
  for(j=0;j<ColumnB;j++)
  {
   cout<<setw(4)<<B[i][j];
  }
  cout<<endl;
 }
  //the operation of multiplication
 for(i=0;i<RowsA;i++)
 {
  for(j=0;j<ColumnB;j++)
  {
   C[i][j]=0;
   for(k=0;k<RowsB;k++)
   {
    C[i][j]+=A[i][k]*B[k][j];
   }
  }
 }
 //Showing result
 cout<<"\nMatrix C, Result : \n";
 cout<<"==================\n";
 for(i=0;i<RowsA;i++)
 {
  for(j=0;j<ColumnB;j++)
  {
   cout<<setw(4)<<C[i][j];
  }
  cout<<endl;
 }
cout<<"The amount above is the result from the matrix A&B that you have input";
return 0;
}


01.jpg

02.jpg

03.jpg

result work:

When the program starts it will pop up the title (header) that asks the user to enter the values for the rows and columns of the matrix A. After you enter the number of rows and columns of the matrix A, the User will then be prompted to enter the number or the element will be placed on the columns and rows in A matrix.
01.jpg

Following are the results of the input matrix A with the value of the number of rows 2 and column 4.
Elements:
02.jpg

The results in the form of a matrix:
03.jpg

After the value or element to appear in A matrix on the next program will be followed by a command to the user to enter a number for the row and column that are organized on a matrix B.

First, the user will be prompted to enter the number of rows, exemplified here by entering the 2 rows and then the program will prompt the user to enter the number of columns that will be shown in matrix B. for the column using 3 for the example.

After you enter the number of rows and columns, then the User will be prompted to enter values or elements that will be shown.
04.jpg

The results of the input element are shown in the form of a matrix B:
05.jpg

Furthermore, the result of the multiplication between the matrices A and B will appear as matrix the following example from c. results of the multiplication Matrix A and B:

06.jpg

On the program limits the number of rows and columns that are defined for matrices A, B, and C is 100 for each row and columns.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Can you make Blogs about C programms too ?

Your contribution cannot be approved because it does not follow the follow me

Your contribution cannot be approved Utopian no longer accept the repository you contributed to.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.15
TRX 0.17
JST 0.028
BTC 68746.72
ETH 2456.17
USDT 1.00
SBD 2.43