"C" for engineers homework

profilemarisela15
homework_5_program.pdf

1. Write a program that will calculate the determinant of a 2x2 and a 3x3 matrix.

The determinant of a 2x2 matrix is defined by:

The determinant of a 3x3 matrix is defined by:

where a,b, c, d, e, f, g, h, and i are real or complex values.

Your program should accept integer values from the user. Your program must allow the user to choose

which determinant to calculate, your program should allow the user to terminate the program when he

chooses to. Your program should include two functions, one for each determinant calculation. You may

use the following function prototypes:

int det_2by2(int mat[ ][ 2], int rows);

int det_3by3(int mat[ ] [3], int rows);

2. You will write a program that will manipulate a one dimensional array according to the

transformations listed below. Your array will hold 25 floating point values. Define a symbolic constant

MAX_SIZE and initialize it to 25. Initialize your array to contain the values from 0.0 to 24.0 in array

indexes 0 – 24. The user will choose the transformation to be performed on the matrix values, i.e.

provide a menu.

Transformations:

Initialize – initialize the array to contain the values from 0.0 to 24.0 in array positions 0 – 24.

Square – square every value in the array

Halve – halve every value in the array

Accumulate – for every array index N, set the value at array index N to be the sum of the values from

index 0 to index N.

Shift – move every value in the array by “n” positions, the user will enter this value.

Reverse – reverse the position of the values in the array, i.e. switch a[0] with a[24], a[1] with a[23], etc.

Use the following function prototypes:

void initialize(float a[], int size);

void square(float a[], int size);

void halve(int float[], int size);

void accumulate(float a[], int size);

void shift(float a[], int size);

void reverse(float a[], int size);