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

Matriks Program: Penjumlahan 2x2

The document contains a C++ program that prompts the user to input two 2x2 matrices. It then calculates and displays the sum of these matrices. The program includes user input handling, matrix display, and the final result output.

Uploaded by

ika
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)
27 views2 pages

Matriks Program: Penjumlahan 2x2

The document contains a C++ program that prompts the user to input two 2x2 matrices. It then calculates and displays the sum of these matrices. The program includes user input handling, matrix display, and the final result output.

Uploaded by

ika
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 <cstdlib>

#include <iostream>

using namespace std;

int main()

int matriks1[2][2], matriks2[2][2], hasil[2][2];

cout << "Input Matriks 1 "<< endl;

cout << "--------------------------------- "<< endl;

cout << "masukkan nilai baris 1, kolom 1 = ";

cin >> matriks1[0][0];

cout << "masukkan nilai baris 1, kolom 2 = ";

cin >> matriks1[0][1];

cout << "masukkan nilai baris 2, kolom 1 = ";

cin >> matriks1[1][0];

cout << "masukkan nilai baris 2, kolom 2 = ";

cin >> matriks1[1][1];

cout << "Input Matriks 2 "<< endl;

cout << "--------------------------------- "<< endl;

cout << "masukkan nilai baris 1, kolom 1 = ";

cin >> matriks2[0][0];

cout << "masukkan nilai baris 1, kolom 2 = ";

cin >> matriks2[0][1];


cout << "masukkan nilai baris 2, kolom 1 = ";

cin >> matriks2[1][0];

cout << "masukkan nilai baris 2, kolom 2 = ";

cin >> matriks2[1][1];

cout << " Matriks 1 " << endl;

cout << matriks1[0][0] << " " << matriks1[0][1] << endl;

cout << matriks1[1][0] << " " << matriks1[1][1] << endl;

cout << " Matriks 2 " << endl;

cout << matriks2[0][0] << " " << matriks2[0][1] << endl;

cout << matriks2[1][0] << " " << matriks2[1][1] << endl;

cout << "Hasil penjumlahan matriks " << endl;

hasil[0][0] = matriks1[0][0] + matriks2[0][0];

hasil[0][1] = matriks1[0][1] + matriks2[0][1];

hasil[1][0] = matriks1[1][0] + matriks2[1][0];

hasil[1][1] = matriks1[1][1] + matriks2[1][1];

cout << hasil[0][0] << " " << hasil[0][1] << endl;

cout << hasil[1][0] << " " << hasil[1][1] << endl;

system("PAUSE");

return 0;

You might also like