0% found this document useful (0 votes)
13 views5 pages

Include

This C++ program allows users to input two matrices A and B, then calculates and displays their product matrix C. It prompts for the dimensions and elements of both matrices, performs matrix multiplication, and outputs the resulting matrix. The program is authored by Freditya Margianto, a student in class TI-C.

Uploaded by

somathsoalmath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Include

This C++ program allows users to input two matrices A and B, then calculates and displays their product matrix C. It prompts for the dimensions and elements of both matrices, performs matrix multiplication, and outputs the resulting matrix. The program is authored by Freditya Margianto, a student in class TI-C.

Uploaded by

somathsoalmath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<iostream>

#include<conio.h>

#include<iomanip>

using namespace std;

int main(void)

int A[100][100],B[100][100],C[100][100],i,j,k,barisa,koloma,barisb,kolomb,barisc,kolomc;

cout<<"Disusun oleh:\n";

cout<<"Nama : FREDITYA MARGIANTO\n";

cout<<"Nim : 5140411150\n";

cout<<"Kelas : TI-C\n";

//masukan ordo matriks A

cout<<"masukan ordo matriks A:"<<endl;

cout<<"======================="<<endl;

cout<<"jumlah baris:";

cin>>barisa;

cout<<"jumlah kolom:";

cin>>koloma;

//masukan matriks A

cout<<"silahkan input matriks A:"<<endl;


cout<<"========================="<<endl;

for(i=0;i<barisa;i++)

for(j=0;j<koloma;j++)

cout<<"\nElemen ke "<<(i+1)<<","<<(j+1)<<":";

cin>>A[i][j];

//cetak matriks A

cout<<"\nMatriks A: \n";

for(i=0;i<barisa;i++)

for(j=0;j<koloma;j++)

cout<<setw(4)<<A[i][j];

cout<<endl;

//masukan ordo matriks B

cout<<"masukan ordo matriks B:"<<endl;

cout<<"======================="<<endl;
cout<<"jumlah baris:";

cin>>barisb;

cout<<"jumlah kolom:";

cin>>kolomb;

//masukan matriks B

cout<<"silahkan input matriks B:"<<endl;

cout<<"========================="<<endl;

for(i=0;i<barisb;i++)

for(j=0;j<kolomb;j++)

cout<<"\nElemen ke "<<(i+1)<<","<<(j+1)<<";";

cin>>B[i][j];

//cetak matriks B

cout<<"\nMatriks B : \n";

for(i=0;i<barisb;i++)

for(j=0;j<kolomb;j++)

cout<<setw(4)<<B[i][j];

}
cout<<endl;

//operasi perkalian

for(i=0;i<barisa;i++)

for(j=0;j<kolomb;j++)

C[i][j]=0;

for(k=0;k<barisb;k++)

C[i][j]+=A[i][k]*B[k][j];

//menampilkan hasil

cout<<"\nMatriks C, Hasil : \n";

cout<<"==================\n";

for(i=0;i<barisa;i++)

for(j=0;j<kolomb;j++)

cout<<setw(4)<<C[i][j];

}
cout<<endl;

cout<<"diatas adalah hasil perkalian matriks A&B yang telah anda inputkan";

return 0;

You might also like