Calculate the determinant

Assignment Help C/C++ Programming
Reference no: EM133112553

C Programming Task

You must make sure that your code runs on Codeblocks .It is your responsibility to submit a .c code that compiles and runs.

Briefing:
This task will assess your ability to solve a problem using these C programming elements: repetition (e.g. for.. or while..), selection (if), structures, two dimensional arrays, pointers, I/O and functions. Your task is to write a C program to:

• **Allow the user to input the size of a matrix. The contents of the matrix are read in from a file, which has a list of 100 float numbers (numbers in the file are <100.00). If the matrix is 3x2, then the first 2 numbers in the list form the first row, the second 2 numbers in the list form the second row ...and so on).
• The matrix must have between 1 and 10 columns and between 1 and 10 rows. The matrix size (rows x columns) is determined by the user, and this information is stored in a struct matrix (specified below) in members int nrows and int ncols.
• The contents of the matrix will also be stored in the struct matrix in member float mValues[10][10].
• Calculate the determinant: Ask the user to choose the row and column to form a 2x2 matrix, which is a subset of the original matrix. The 2x2 matrix contents must be stored in a new struct matrix variable, along with its size. The determinant of this matrix is then calculated. (See sample run of program below).
• Find the inverse of the 2x2 matrix: The inverse matrix contents must be stored in a new struct matrix variable, along with its size. ##
• Loop from ** to ##, but allow the user some way of exiting the loop and stopping the program

The program shall define a structure to hold information about the matrices as follows (only define one structure, but declare 3 structure variables: one for the original matrix, one for the 2x2 sub matrix and one for the inverse):

struct matrix
{
float mValues[10][10]; // to hold the values in the matrix, up to 10 rows x 10 columns
int nrows; // to hold the number of rows used in mValues
int ncols; // to hold the number of columns used in mValues
};

Notes (refer to mark scheme for more details):

1. The array that holds the matrix values has maximum size 10x10, which means that the program must be able to work with any array up to that size. For this program, the minimum array size allowed is 1 x 1.

2. A sample .txt file with 100 numbers is available on ACS130 Blackboard. Please note that you will need to test your code thoroughly to cover every possible scenario (eg to get a det=0). I will be using a different test data to test your program.

3. The program must display to the screen the contents of each matrix in the program, after it has been input or created.

4. The program must allow both square and non-square matrices, e.g. 3 x 3 is square, 3 x 4 is not square.

5. You must program defensively. The program must check for out ofrange values for rows and columns at every possible instance. The program must ask the user to enter again if incorrect. You also need to check if the input file is available. You also need to take into consideration things like: possibility of generating a 2x2 matrix (because the input matrix is smaller, eg, 2x1), having a 1x1 matrix, and finding the inverse when the determinant is 0 or does not exist.

6. You cannot use global variables. You will get 0 for the whole code. #define can be used.

7. You cannot use while(1) loops. You will get 0 for the whole code. You can use a while(OK) loop where OK is a variable that is, for eg, 0 or 1

8. You cannot use break (unless it is part of a switch case).

9. You cannot use goto, continue, jump.

10. The program must include main( ) and the following 4 functions. The function prototypes must be as follows:

void matrixInput(struct matrix *mat, FILE *in); /* to input the size (number of rows and columns) of the matrix, and read in the values from the file (using fscanf) into the 2D array that makes up the matrix */ NOTE, the file opening and checking occurs in main(), eg FILE
*fin; fin=fopen(" xyz.txt",'r'); then use fin in the function call.

void matrixDisplay(struct matrix mat); /* to display the values in the 2D array that makes up the matrix*/

float matrixDeterminant(struct matrix m1, struct matrix *m2, int
*check); /* to find the determinant of M2, where M2 is a 2x2 subset matrix of m1; returns determinant to main. If determinant is not equal to 0, check =1; if determinant=0, cheCK=2, otherwise check is 0 (when size of matrix <2x2). check variable is needed for the inverse. This function does not display either M1 or M2. */

void matrixInverse(struct matrix m2, float determinant, struct matrix
*m3); /* to find the inverse (if possible) of the 2X2 matrix; this function does not display either M2 or m3. */

11. You are free to add extra functions, for example, for out-of-range checks (for rows and columns), or any other defensive programming required, but you must have the 4 functions listed above.

Attachment:- C Programming - Structures and 2D arrays.rar

Reference no: EM133112553

Questions Cloud

What is the net present value of the project : Your company has five delivery trucks that are getting old and only have two years of useful life left in them. As they are not fuel efficient and need a lot of
Calculate the present value of the bond : On January 1st, 20Y1 Buckle Corporation issued $160,000,000 of 10-year, 12% bonds at a market interest rate of 15%. Calculate the present value of the bond
What is the project payback period : What is the project's payback period? Round your answer to two decimal places.
Outline and detail the ethical decision-making model : Mary Rogers graduated from Deakin and joined a financial advice firm. She succeeded in passing the three month probation period, and she now works full-time wit
Calculate the determinant : Calculate the determinant: Ask the user to choose the row and column to form a 2x2 matrix, which is a subset of the original matrix
Prepare the adjusting journal entries as of august : A telephone bill in the amount of $122 covering August charges is unpaid at August 31. Prepare the adjusting journal entries as of August
Regression equation of e : Given the fitted the regression equation of E(Price ¦ Weight) =-260 + 3721 Weight and an RMSE from the regression of 32, then which of the following is the appr
Discuss the credit risk management measures : Discuss the credit risk management measures available to a financial institution
Capital structure and the percentage change in wacc : MGMT2023 paid dividends of $10 last year. The dividends are expected to grow into perpetuity at a rate of 7%. The price of each stock is set at $60 per share.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd