0% found this document useful (0 votes)
6 views

Assignment 21

Assignment 2 due: monday, March 22, 2010 (till the labs are open) to submit: Make a folder with name as your roll number. Place the three programs in this folder and paste it on xeon.

Uploaded by

Najwa Shaukat
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assignment 21

Assignment 2 due: monday, March 22, 2010 (till the labs are open) to submit: Make a folder with name as your roll number. Place the three programs in this folder and paste it on xeon.

Uploaded by

Najwa Shaukat
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Computer Programming (CS-F) ASSIGNMENT 2 Due: Monday, March 22, 2010 (till the labs are open) Note:

No assignment will be accepted via email. It has to be pasted on xeon in the submission folder. Also, late assignment will NOT be accepted. To submit: Make a folder with name as your roll number. Place the three programs in this folder and paste it on xeon. QUESTION 1 We want to implement an upper triangular matrix (find out what it is from the internet). It is a matrix with nonzero entries on the diagonal and non-zero entries above the main diagonal. The entries below the main diagonal are zero. Since entries below the main diagonal are zero we dont want to store them. Write a function that allocates memory to an upper triangular matrix. It will have n entries in row 1, n-1 entries in row 2, n-3 entries in row 3 and so on. (n should be input from the user). void AllocateTriangularMatrix(int ***arr,int n) Write a function to deallocate this matrix. Also, write a function to input the contents of this matrix from a user. Test all these functions by calling them in the proper sequence from main(). Also write the main function to test your program. QUESTION 2 Find out how matrix multiplication is done. Implement this function that multiplies two matrices A and B and stores the result in C. Make sure that for C a null pointer is passed. If it is not NULL then you should return false. Otherwise allocate the matrix C in this function (best to call Allocate2DArray function (from lab) from this function). On successful multiplication the function should return true. The matrix A has dimensions mxn, Matrix B has dimensions nxr. What will be the dimensions of C??? bool MultiplyMatrices(int **A, int **B, int ***C, int m, int n, int r) QUESTION 3 Write a function that takes as input a 2D array and its dimensions. It should return the maximum element in each row of the array. Since there are more than one rows in 2D array so you have to return an array that contains maximum of each row. The allocation of this array of maximum entries should also be done in your function int *MaxInEachRow(int **arr, int row, int size)

page 1 of 1

You might also like