Review Test 2 - Review 2 Test Version C 1. Write a menu...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Review 2 Test Version C 1.Write a menu driven program that allows a user to specify matrices operation: add, subtract, multiply. The user should be able to enter the two matrices and choose the operation to be performed in the main function. Based upon user input, one of the functions must be called and the result must be displayed. #include <stdio.h> void add(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) void subtract(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) void multiply(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) void add(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) { int iaaMatrix3[2][2] int i,j i for (i=0 { for (j=0 { iaaMatrix3[i][j] = iaaMatrix1[i][j]+iaaMatrix2[i][j] } } printf("\nThe resulting matrix is:\n\n") for (i=0 { for (j=0 { printf("%d\t",iaaMatrix3[i][j]) } printf("\n") } } void subtract(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) { int iaaMatrix3[2][2] int i,j i for (i=0 { for (j=0 { iaaMatrix3[i][j] = iaaMatrix1[i][j]-iaaMatrix2[i][j] } } printf("\nThe resulting matrix is:\n\n") for (i=0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

Review Test 2 - Review 2 Test Version C 1. Write a menu...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online