CSCI 1300 ASSIGNMENT 2 - SECTION 4 Sem 2 1920
CSCI 1300 ASSIGNMENT 2 - SECTION 4 Sem 2 1920
𝑝 𝑞 𝑝𝑎 + 𝑞𝑑 𝑝𝑏 + 𝑞𝑒 𝑝𝑐 + 𝑞𝑓
𝑠 ] x [𝑎 𝑏 𝑐
[𝑟 ] = [ 𝑟𝑎 + 𝑠𝑑 𝑟𝑏 + 𝑠𝑒 𝑟𝑐 + 𝑠𝑓 ]
𝑡 𝑢 𝑑 𝑒 𝑓
𝑡𝑎 + 𝑢𝑑 𝑡𝑏 + 𝑢𝑒 𝑡𝑐 + 𝑢𝑓
Matrix 3 x 2 Matrix 2 x 3 Matrix 3 x 3
The determinant of a matrix represented by two vertical lines on either side |A| is a special number
that can be calculated from a square matrix. Figure 2 shows an example of how a determinant for matrix
A is calculated :
Matrix A = [ 𝑎 𝑏 ]
𝑐 𝑑
| A | = ad - bc
𝑎 𝑏 𝑐
Matrix B = [ 𝑑 𝑒 𝑓 ]
𝑔 ℎ 𝑖
Write a C++ program that multiplies 2 matrices and return the determinant of the multiplied matrix.
Your program shall include the following:
a) Define two 2 dimensional arrays, P and Q that each represents a matrix of size 3 x 2 and a matrix
of size 2 x 3. Request the user to enter the values for the 2 arrays using advanced pointer
notations (refer to your slides for the list of array pointer notations).
b) Create a function named multMatrix() that passes as arguments, the values of array P and Q,
multiplies them and store the results in a new matrix PQ. Use pointer notations to multiply your
arrays. Display your multiplied arrays.
c) Create a function named findDeterm() that passes as argument, the values of array PQ and return
its determinant from the function. Use advanced pointer notations to perform your calculation.
Display your result in main().
The basic program and function stubs are given below as a guideline.
1
Department of Computer Science, KICT 02 JULY 2020
#include <iostream>
using namespace std;
int main()
{
Sample Output :
Matrix P x Q is :
| 33 38 57 |
| -14 -18 -27 |
| 24 34 51 |
1 -2 8