Review Test 2

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

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

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/19/2008 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas.

### 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
Ask a homework question - tutors are online