Advertisement
aiNayan

5(vii)

Nov 28th, 2020 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int matrixA[10][10], matrixB[10][10], add[10][10], sub[10][10], row, col, r = 3, c = 3;
  5. puts("Enter A matrix row by row: ");
  6. for (row = 0; row < r; row++) {
  7. for (col = 0; col < c; col++)
  8. scanf("%d", &matrixA[row][col]);
  9. }
  10. puts("Enter B matrix row by row: ");
  11. for (row = 0; row < r; row++) {
  12. for (col = 0; col < c; col++)
  13. scanf("%d", &matrixB[row][col]);
  14. }
  15. for (row = 0; row < r; row++) {
  16. for (col = 0; col < c; col++) {
  17. add[row][col] = matrixA[row][col] + matrixB[row][col];
  18. sub[row][col] = matrixA[row][col] - matrixB[row][col];
  19. }
  20. }
  21. puts("Addition:");
  22. for (row = 0; row < r; row++) {
  23. for (col = 0; col < c; col++)
  24. printf("%d", add[row][col]);
  25. printf("\n");
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement