Assignment 01 Abdullah
Assignment 01 Abdullah
Reg#931-FET/BSEE/F21
Section: A
Assignment#1(CLO2)
Readme.txt:
Compile and link the main program: gcc main.c -L. -lAbdullah -o main
Run/Execute the Program and then enter two matrices to get the output.
1. Create Abdullah.h:
#ifndef ABDULLAH_H
#define ABDULLAH_H
#endif
2. Create Abdullah.c:
#include <stdio.h>
#include "Abdullah.h"
1
printf("Enter matrix elements (3x3):\n");
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
scanf("%lf", &Mat[i][j]);
}
2
Mat_B[0][0] = inv_det * (Mat_A[1][1] * Mat_A[2][2] - Mat_A[1][2] *
Mat_A[2][1]);
Mat_B[0][1] = inv_det * (Mat_A[0][2] * Mat_A[2][1] - Mat_A[0][1] *
Mat_A[2][2]);
Mat_B[0][2] = inv_det * (Mat_A[0][1] * Mat_A[1][2] - Mat_A[0][2] *
Mat_A[1][1]);
Mat_B[1][0] = inv_det * (Mat_A[1][2] * Mat_A[2][0] - Mat_A[1][0] *
Mat_A[2][2]);
Mat_B[1][1] = inv_det * (Mat_A[0][0] * Mat_A[2][2] - Mat_A[0][2] *
Mat_A[2][0]);
Mat_B[1][2] = inv_det * (Mat_A[0][2] * Mat_A[1][0] - Mat_A[0][0] *
Mat_A[1][2]);
Mat_B[2][0] = inv_det * (Mat_A[1][0] * Mat_A[2][1] - Mat_A[1][1] *
Mat_A[2][0]);
Mat_B[2][1] = inv_det * (Mat_A[0][1] * Mat_A[2][0] - Mat_A[0][0] *
Mat_A[2][1]);
Mat_B[2][2] = inv_det * (Mat_A[0][0] * Mat_A[1][1] - Mat_A[0][1] *
Mat_A[1][0]);
}
int main() {
double A[3][3], B[3][3], C[3][3];
Abdullah_Get(A);
Abdullah_Show(A);
Abdullah_Get(B);
Abdullah_Show(B);
Abdullah_Add(A, B, C);
3
printf("Sum of matrices:\n");
Abdullah_Show(C);
Abdullah_Mul(A, B, C);
printf("Multiplication of matrices:\n");
Abdullah_Show(C);
Abdullah_Inv(A, C);
printf("\nInverse of Matrix A:\n");
Abdullah_Show(C);
return 0;
}