/* Program to find the sum of two matrices & store the result in new one */ /* Problem 18 */ #include #include main() { int a[5][5],b[5][5],c[5][5]; int i,j,m,n; clrscr(); printf("Please enter the matrix's m (in mxn) : "); scanf("%d",&m); printf("Also enter the matrix's n (in mxn) : "); scanf("%d",&n); printf("\nEnter the elements for matrix 'A' (separated by or ) : "); printf("\n\n"); for (i = 0; i < m; i++) for (j = 0; j < n; j++) scanf("%d",&a[i][j]); printf("\nAnd enter the elements for matrix 'B' (separated by or ) : "); printf("\n\n"); for (i = 0; i < m; i++) for (j = 0; j < n; j++) scanf("%d",&b[i][j]); printf("\n\nThe sum of the two matrices given is as follows,"); printf("\n\n"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { c[i][j] = a[i][j] + b[i][j]; printf("%3d",c[i][j]); } printf("\n"); } printf("\n\nPress any key to exit..."); getch(); }