0% found this document useful (0 votes)
20 views2 pages

Atik

The document describes a C++ program that performs matrix multiplication on two 3x3 matrices, C and D, and stores the result in a third matrix, E. It prompts the user to input the elements of matrices C and D, then displays each matrix. It then performs the multiplication C * D using nested for loops and stores the result in E. Finally, it displays the result matrix E.

Uploaded by

Tyea Jutex
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Atik

The document describes a C++ program that performs matrix multiplication on two 3x3 matrices, C and D, and stores the result in a third matrix, E. It prompts the user to input the elements of matrices C and D, then displays each matrix. It then performs the multiplication C * D using nested for loops and stores the result in E. Finally, it displays the result matrix E.

Uploaded by

Tyea Jutex
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Eka Dian Nuraini

09.55201.592
Sore A / Rabu jam 16.00
Tugas Uas praktikum sruktur data
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
void main()
{
int C[3][3],D[3][3],E[3][3],i,j,k;
clrscr();

//masukkan matrix C
cout<<"Silahkan input matrik C : \n";
cout<<"------------------------- \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"Elemen ke "<<(i+1)<<","<<(j+1)<<" : ";
cin>>C[i][j];
}
}

//cetak matrix C
cout<<"\nMatrik C : \n";;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<setw(4)<<C[i][j];
}
cout<<endl;
}
cout<<endl;

//masukkan matriks D
cout<<"Silahkan input matrik D : \n";
cout<<"------------------------- \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"Elemen ke "<<(i+1)<<","<<(j+1)<<" : ";
cin>>D[i][j];
}
}
//cetak matrix D
cout<<"\nMatrik D : \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<setw(4)<<D[i][j];
}
cout<<endl;
}

//Operasi Perkalian
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
E[i][j]=0;
for (k=0;k< 3;k++)
{
E[i][j]+= C[i][k]*D[k][j];
}
}
}

//Menampilkan hasil
cout<<"\nMatrik E, Hasil : \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<setw(4)<<E[i][j];
}
cout<<endl;
}
cout<<endl;
getch();
}

Hasil :

You might also like