Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Please consider saving the code of 'array function'(from my pastebin) as 'functions.c' in the same folder as the following code is saved*/
- #include<stdio.h>
- #include"functions.c"
- int main(){
- int order;
- int sum;
- printf("Only square matrices are allowed\nWhat is the order of matrices: ");
- scanf("%d", &order);
- int mat1[order][order];
- input_matrix(order, mat1);
- printf("Matrix 1 is:\n");
- display_matrix(order, mat1);
- int mat2[order][order];
- input_matrix(order, mat2);
- printf("Matrix 2 is:\n");
- display_matrix(order, mat2);
- int mat_result[order][order];
- for(int i=0; i<order; i++){
- for(int j=0; j<order; j++){
- sum=0;
- for(int k=0; k<order; k++){
- sum = sum+mat1[i][k]*mat2[k][j];
- }
- mat_result[i][j] = sum;
- }
- }
- printf("Multiplication is: \n");
- display_matrix(order, mat_result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement