Bachelor of Technology in Information Technology


Matrix Multiplication ALGORITHM



Download 0,65 Mb.
bet12/14
Sana20.03.2022
Hajmi0,65 Mb.
#502184
1   ...   6   7   8   9   10   11   12   13   14
Bog'liq
PSP Lab Manual

Matrix Multiplication ALGORITHM:


Step 1: Start.
Step 2: declare m, n, p, q, c, d, k, sum ← 0, first[10][10], second[10][10], multiply[10][10].
Step 3: print enter number of rows and columns of first matrix Step 4: read m and n
Step 5: print enter elements of first matrix
Step 6: repeat step until c less than m and d less than n Step 7: read first[c][d]
Step 8: print enter number of rows and columns of second matrix
Step 9: read p and q
Step 10: if n is not equal to p
Print matrix cannot be multiplied with each other
Step 11: else
Print enter elements of second matrix
Step 12: repeat step until c less than p and d less than q Step 13: read second[c][d]
Step 14: repeat step until c less than m, d less than q, and k less than p Step 15: sum ←sum + first[c][k]*second[k][d]
Multiply[c][d] ← sum Sum← 0
Step 16: print product of the matrix
Step 17: repeat step until c less than m and d less than q Step 18: print multiply[c][d]
Step 19: Stop.


SOURCE CODE:


#include #include int main()


{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];

printf("Enter number of rows and columns of first matrix\n"); scanf("%d%d", &m, &n);


printf("Enter elements of first matrix\n");

for (c = 0; c < m; c++)


for (d = 0; d < n; d++) scanf("%d", &first[c][d]);

printf("Enter number of rows and columns of second matrix\n"); scanf("%d%d", &p, &q);


if (n != p)


printf("The matrices can't be multiplied with each other.\n"); else
{
printf("Enter elements of second matrix\n");

for (c = 0; c < p; c++) for (d = 0; d < q; d++)


scanf("%d", &second[c][d]);

for (c = 0; c < m; c++)


{
for (d = 0; d < q; d++)
{
for (k = 0; k < p; k++)
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum; sum = 0;
}
}
printf("Product of the matrices:\n");

for (c = 0; c < m; c++) { for (d = 0; d < q; d++)


printf("%d\t", multiply[c][d]);

printf("\n");


}
}
getch();
}








  1. Download 0,65 Mb.

    Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   14




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish