luc067.c (1419B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 08 Feb 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* Write a program to multiply any two 3 x 3 matrices. 9 */ 10 11 /* Let Us C, Chap- 14 (Multidimensional Arrays), Qn No.: C(g) */ 12 13 /* This file is auto-generated by a bot. */ 14 /* This code is not compiled; it is for reference only. */ 15 16 17 #include <stdio.h> 18 #include <stdlib.h> 19 20 int main() 21 { 22 int mat1[3][3], mat2[3][3], res[3][3]; 23 int i, j, k; 24 25 printf("Enter elements of first 3x3 matrix:\n"); 26 for (i = 0; i < 3; i++) 27 for (j = 0; j < 3; j++) 28 scanf("%d", &mat1[i][j]); 29 30 printf("Enter elements of second 3x3 matrix:\n"); 31 for (i = 0; i < 3; i++) 32 for (j = 0; j < 3; j++) 33 scanf("%d", &mat2[i][j]); 34 35 // Initialize result matrix to 0 36 for (i = 0; i < 3; i++) 37 for (j = 0; j < 3; j++) 38 res[i][j] = 0; 39 40 // Multiplication Logic 41 for (i = 0; i < 3; i++) 42 { 43 for (j = 0; j < 3; j++) 44 { 45 for (k = 0; k < 3; k++) 46 { 47 res[i][j] += mat1[i][k] * mat2[k][j]; 48 } 49 } 50 } 51 52 printf("\nResult of Multiplication:\n"); 53 for (i = 0; i < 3; i++) 54 { 55 for (j = 0; j < 3; j++) 56 { 57 printf("%4d ", res[i][j]); 58 } 59 printf("\n"); 60 } 61 62 return 0; 63 }