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

Week 5 Matrices I

This document contains a practice lab covering topics related to matrices and two dimensional arrays. It includes questions to write functions that initialize and perform operations like addition and subtraction on matrices of user-defined dimensions.

Uploaded by

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

Week 5 Matrices I

This document contains a practice lab covering topics related to matrices and two dimensional arrays. It includes questions to write functions that initialize and perform operations like addition and subtraction on matrices of user-defined dimensions.

Uploaded by

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

Lab – V: Data Structures

Q1 Total
Matrices – I
10 + 5 + 5 + 10 30

1. This practice lab covers the following one week of lectures in the Syllabus. You are expected to watch these videos prior
to doing this lab.

Lecture Topics Reading


9 Dynamic Multidimensional arrays: Two 1. Two dimensional arrays: https://youtu.be/tVRjl5byrzY
10 dimensional arrays, two dimensional 2. Two dimensional arrays using pointers: https://youtu.be/khAU5tGMPTs
arrays using pointers, dynamic arrays & 3. Dynamic arrays: https://youtu.be/m2FUMo28CSk
two-dimensional dynamic arrays. 4. Two dimensional dynamic arrays: https://youtu.be/34jVHuacTGM
5. Matrix addition: https://youtu.be/YfNx0K7kljQ

Q1) Write a program that:


1 A function that initializes 𝑋𝑚×𝑛 and 𝑌𝑙×𝑘 , where {m, n, l, k} are user defined and also its 10
contents.

2 A function that evaluates 𝑍 = 𝑋 + 𝑌. 5

3 A function that evaluates 𝑍 = 𝑋 − 𝑌. 5

4 A function called ‘print’ that simply prints the answer. 10

Rubrics (Associated Marks)

S. No. Content Meets Criteria (1) Marks Does not meet expectations (0) Marks

1 Indentation Perfect 100% Code not indented properly 0


2 Code works Code compiles and executes properly for 100% Code has errors Based on
any variable sized matrices the code
3 Comments Code is properly commented 100% Code is not properly commented. 0
Sample Output:

Inputs by the user are marked in red.

Dear User. What is your name?


> Aqib

Dear Aqib, please tell me the dimensions of matrix X


>3
>2
Dear Aqib, please input the contents of X.
>3
>6
>9
>0
>8
>1

Dear Aqib, Matrix X has the following contents:


[3 6]
[9 0]
[8 1]

Dear Aqib, please tell me the dimensions of matrix Y


>3
>2
Dear Aqib, please input the contents of Y.
>2
>1
>0
>3
>4
>1

Dear Aqib, Matrix Y has the following contents:


[2 1]
[0 3]
[4 1]

Dear Aqib, Z = X + Y is shown below:


[5 7]
[9 3]
[12 2]

Dear Aqib, Z = X - Y is shown below:


[1 5]
[9 -3]
[4 0]

You might also like