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

Assignment 8

The document provides instructions for an assignment on programming and data structures involving matrices. It consists of two problems: 1. Write functions to (a) interchange the major and minor diagonals of a matrix, (b) multiply two matrices, and (c) find saddle points of a matrix. Also write a main function to test these functions on three given matrices A, B and C. 2. Write a main function to dynamically allocate a square matrix A of size n x n. Also write functions to (a) multiply A with a scalar, (b) compute A to the power p, (c) compute the matrix expression 3A4 – 5A3 + 7A2 – 2A, and

Uploaded by

Tumpy Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assignment 8

The document provides instructions for an assignment on programming and data structures involving matrices. It consists of two problems: 1. Write functions to (a) interchange the major and minor diagonals of a matrix, (b) multiply two matrices, and (c) find saddle points of a matrix. Also write a main function to test these functions on three given matrices A, B and C. 2. Write a main function to dynamically allocate a square matrix A of size n x n. Also write functions to (a) multiply A with a scalar, (b) compute A to the power p, (c) compute the matrix expression 3A4 – 5A3 + 7A2 – 2A, and

Uploaded by

Tumpy Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Programming and Data Structure Laboratory (CS19001)

Spring 2022-23

Assignment for Week 8 (May 15, 2023)

Total Marks: 100 Duration: 3 hours

INSTRUCTIONS
a) All programs should be written in C.
b) The file containing your solution to problem ‘x’ should be named roll-week8-probx.c where ‘roll’ is your roll
number.
c) Use indentation and comments as necessary. You are allowed to consult your books, notes or manual pages.
d) Upload the files separately on Moodle.

PROBLEMS

1. Write the following functions in C. [(10+10+20)+10=50]


a) Write the following functions for two-dimensional matrices. Pass the parameters suitably to the
functions.
i) A function to interchange the major and minor diagonals of a matrix passed as parameter.
ii) A function to multiply two matrices of sizes m x n and n x p, to produce a product matrix of
size m x p.

iii) A function to print all saddle points of a given matrix with m rows and n columns. The (i,j)-
th element is said to be a saddle point if it is the smallest element in row i and largest element
in column j, or vice versa.
b) Write a main function to read three matrices A, B and C, and test the three functions suitably as
mentioned above. Generate the outputs in suitably formatted form.

2. Write a main function to dynamically allocate a two-dimensional square matrix A of size n x n. Write the
following functions:
a) Multiply a matrix A with a scalar k, where both A and k are passed as parameters.
b) Compute A to the power p, where both A and p are passed as parameters. The result matrix is also
returned via parameter (space for the result matrix should also be dynamically allocated in the main
function).
c) Compute and print the matrix expression: 3A4 – 5A3 + 7A2 – 2A.

d) Given a matrix A of dimension 3 x 3, compute and return the determinant of the matrix.

The outputs must all be generated in suitably formatted form. [10+15+15+10]

You might also like