Question: C++ language . Kindly solve both questions in visual studio 2019. The test cases are also provided with the questions. TEST CASE FOR Q4 TEST(matrixMult,

C++ language. Kindly solve both questions in visual studio 2019. The test cases are also provided with the questions.

C++ language. Kindly solve both questions in visual studio 2019. The test

TEST CASE FOR Q4

TEST(matrixMult, T1) { int mat1[4][4] = { { 1, 1, 1, 1 },{ 2, 2, 2, 2 },{ 3, 3, 3, 3 },{ 4, 4, 4, 4 } };// 4*4 int mat2[4][4] = { { 1, 1, 1, 1 },{ 2, 2, 2, 2 },{ 3, 3, 3, 3 },{ 4, 4, 4, 4 } };//4*4

EXPECT_EQ(240, mat1, mat2, 4, 4, 4, 4); EXPECT_EQ(400, multiplyMatrix(mat1, mat2, 4, 4, 4, 4)) }

TEST(matrixMult, T2) { int mat1[4][4] = { { 1, 1, 1, 1 },{ 2, 2, 2, 2 },{ 3, 3, 3, 3 },{ 4, 4, 4, 4 } };// 4*4 int mat2[4][3] = { { 1, 1, 1, 1 },{ 2, 2, 2, 2 },{ 3, 3, 3, 3 } };//4*3

EXPECT_EQ(240, mat1, mat2, 4, 4, 4, 3); EXPECT_EQ(400, multiplyMatrix(mat1, mat2, 4, 4, 4, 3)) }

Q2

2. Create a two dimensional array and initialize it with random integer values in between 1- 10. Your task is to do the followings; a) Write a method second_Max_RowSum(T a[][], int rowSize) that will calculate and return the second maximum sum of rows. b) Write a method sortRows that will sort the each Row of 2-D array into ascending order. c) Write a method swap_Odd_Rows that will swap the values of odd rows.

TEST CASE FOR Q2

TEST(Matrix, T1) { int a[3][4] = { {3,2,0,1} ,{5,6,7,4} ,{9,8,3,11} }; int res[3][4] = { {0, 1, 2, 3} , {4, 5, 6, 7} ,{3,8, 9, 11} }; EXPECT_EQ(22, second_Max_RowSum(a, 3, 4)); int** expect = sortRows(a, 3, 4); for (int i = 0; i

}

//Write test cases for type double

4. This sample problem requires you to multiply 2 matrices and given the sum of the resultant matrix. For example, given the matrices M and N, you are required to multiple these matrices. Let A be the resultant matrix. Thenyour final answer should be element-wise sum of A. Note that the dimensions of M and N must match. The only operation allowed is transpose (i.e. changing the rows into columns and columns into rows). If the dimensions of N does not match with those of M, you try to take the transpose of N. Example 1 2 3 4 5 6 7 8 9 10 11 12 M= Na 1 0 3 4 5 6 1 8 0 0 0 12 A= 26 52 48 26 58 132 96 58 90 212 144 90

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!