Table of Contents

Lab03 - Types and arrays

Arrays and pointers

int arr[10];

int n = 5;
char vars[n];

float coeffs[] = {4.2, 0.12, 8.7773};

Task 1: Static arrays

Write a program which will calculate the dot product of two vectors (arrays). Each array should contain 3 elements. You should code the values for one of the elements, and prompt the user at run-time for the values of the second. When you have this in place, THEN alter your code to make use of a function which takes two arrays, and returns the dot product.

Task 1b: Functions

Create a separate function in your code to calculate the dot product. You should use pointers inside your function.

Task 2: Matrix Multiplication

Using your existing code as a base, ask the user for 9 numbers. Construct a 2D array (3×3) to store these in.

Calculating the resulting matrix from multiplying this 2D array with the other vector.