Project Cse
Project Cse
h>
#include <stdlib.h>
int r, k;
printf("Enter row: ");
scanf("%d", &r);
printf("Enter column: ");
scanf("%d", &k);
printf("Enter elements of first matrix: ");
int a[r][k], b[r][k], c[r][k];
for (int i = 0; i < r; i++) {
for (int j = 0; j < k; j++) {
scanf("%d", &a[i][j]);
}
}
printf("Enter elements of second matrix: ");
for (int i = 0; i < r; i++) {
for (int j = 0; j < k; j++) {
scanf("%d", &b[i][j]);
}
}
int choice;
do {
printf("\nChoose the matrix operation,\n");
printf("----------------------------\n");
printf("1. Addition\n");
printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Exit\n");
printf("----------------------------\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
add(r, k, a, b, c);
printf("Sum of matrix: \n");
display(r, k, c);
break;
case 2:
subtract(r, k, a, b, c);
printf("Subtraction of matrix: \n");
display(r, k, c);
break;
case 3:
multiply(r, k, a, b, c);
printf("Multiplication of matrix: \n");
display(r, k, c);
break;
case 4:
printf("Thank You.\n");
exit(0);
default:
printf("Invalid input.\n");
printf("Please enter the correct input.\n");
}
} while (1);
return 0;
#Algorithm:
1.Start
11.When the value of choice is 1 use add function then use display function to show the value
12.When the value of choice is 2 use substract function then use display function to show the
value
13.When the value of choice is 3 use multiply function then use display function to show the
value
15.When choice is anything else show “Please enter the correct input “And run from the
beginning
16.stop