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

Program: Using Using Using Using Using Namespace Class Static Void String

The document defines a program that performs matrix multiplication. It declares two 2x2 integer matrices, matriks1 and matriks2, and gets user input to populate their values. It then displays the individual matrices. The values of each element in the two matrices are stored in separate variables and used to calculate the elements of the result matrix through multiplication based on matrix multiplication rules. The result matrix is displayed.

Uploaded by

Nur Hidayat
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)
32 views2 pages

Program: Using Using Using Using Using Namespace Class Static Void String

The document defines a program that performs matrix multiplication. It declares two 2x2 integer matrices, matriks1 and matriks2, and gets user input to populate their values. It then displays the individual matrices. The values of each element in the two matrices are stored in separate variables and used to calculate the elements of the result matrix through multiplication based on matrix multiplication rules. The result matrix is displayed.

Uploaded by

Nur Hidayat
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
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{

int x, y;
int[,] matriks1;
int[,] matriks2;

matriks1 = new int[2,2];


matriks2 = new int[2,2];

Console.Write("matriks1\n");
Console.WriteLine("---------------");
Console.WriteLine();

for (x = 0; x < 2; x++)


{
for (y = 0; y < 2; y++)
{
Console.Write("Matriks1=");
matriks1[x, y] = int.Parse(Console.ReadLine());

}
}
Console.WriteLine();

Console.WriteLine();
for (x = 0; x < 2; x++)
{
for (y = 0; y < 2; y++)
{
Console.Write("Matriks2=");
matriks2[x, y] = int.Parse(Console.ReadLine());

}
}

//tampilan
for (x = 0; x < 2; x++)
{
Console.WriteLine();
Console.WriteLine();
for (y = 0; y < 2; y++)
{
Console.Write(matriks1[x, y]+" ");
}
}
Console.WriteLine();
for (x = 0; x < 2; x++)
{
Console.WriteLine();
Console.WriteLine();
for (y = 0; y < 2; y++)
{
Console.Write(matriks2[x, y] + " ");
}

Console.WriteLine();
Console.WriteLine();
int m1b1k1 = matriks1[x = 0, y = 0];
int m1b1k2 = matriks1[x = 0, y = 1];
int m1b2k1 = matriks1[x = 1, y = 0];
int m1b2k2 = matriks1[x = 1, y = 1];

int m2b1k1 = matriks2[x = 0, y = 0];


int m2b1k2 = matriks2[x = 0, y = 1];
int m2b2k1 = matriks2[x = 1, y = 0];
int m2b2k2 = matriks2[x = 1, y = 1];

int b1k1 = (m1b1k1 * m2b1k1) + (m1b1k2 * m2b2k1);


int b1k2 = (m1b1k1 * m2b1k2) + (m1b1k2 * m2b2k2);
int b2k1 = (m1b2k1 * m2b1k1) + (m1b2k2 * m2b2k1);
int b2k2 = (m1b2k1 * m2b1k2) + (m1b2k2 * m2b2k2);
int[,] hasil = new int[2,2] {{ b1k1, b1k2},{ b2k1, b2k2 }};
matriks2[x, y] = int.Parse(Console.ReadLine());
foreach (int hasil1 in hasil)
{
Console.Write(hasil1);
}

Console.WriteLine();

Console.ReadKey();
}
}
}

You might also like