Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

question 1 Exercise: matrix calculator In this question you are required to write a C program that performs basic arithmetic operations on square matrices. The

question 1
Exercise: matrix calculator
In this question you are required to write a C program that performs basic arithmetic operations on square matrices. The program should allow the user to enter up to a pair of matrices + an operation to perform addition, subtraction, multiplication, or, and, not, transpose. Then display the result accordingly. The numbers in the matrix can be whole, rational and even complex
Examples of input / output
Explanation of the syntax (2,2:1,2,3,4) Kotex
(2,2:1,2,3,4) represents a matrix in a compact form and includes the following elements:
-(2,2) matrix size:
a. The first number (2) indicates the number of rows in the matrix.
b. The second number (2) indicates the number of columns in the matrix.
- : separates the size of the matrix from its values.
-1,2,3,4 the values in the matrix:
a. The values are separated by commas and arranged in consecutive lines.
b. In this case, the first row contains the values 1 and 2, and the second row contains the
The values 3 and 4.
Input requirements:
Below is an example of the input and output of the program. The program receives a calculation action from the user and prints the output like this in a loop until the string END is entered. (reminiscent of the terminal interface) when the END string is received, the program exits.
(2,2:1,2,3,4)
(2,2:5,6,7,8)
ADD
(2,2:6,8,10,12)
(2,2:9,8,7,6)
(2,2:1,2,3,4)
SUB
(2,2:8,6,4,2)
(2,2:1,2,3,4)
(2,2:5,6,7,8)
MUL
(2,2:19,22,43,50)
END
explanation:
In the first input, the user enters two 2x2 matrices with the values (2,21,2,3,4)
-(2,2:5,6,7,8), and asks to add (ADD) the resulting output is a new matrix
(2,2:6,8,10,12)2 with the values x2 in size In the second input, the user again enters two 2x2 matrices with the values (2,2:9,8,7,6)-
(2,21,2,3,4), and asks to perform a subtraction (SUB) The resulting output is a new matrix with the result of the subtraction
In the third input, the user enters two 2x2 matrices with the values (2,21,2,3,4 and 1-(2,25,6,7,8), and requests to perform a multiplication. (MUL) The resulting output is a new matrix with the result of the multiplication
At the end, the user presses the string "END" to terminate the program.
Notes on format and assumptions
A proper port can be placed! And that there are no spaces in the input anywhere (only a new line at the end of a line). In the case of a binary operation, but the matrices contain values that differ from 110. ERR must be printed. But to continue with the program. Beyond that, it can be assumed that the input is correct
Nothing can be assumed about the size of the matrix except that it is square. The maximum string length in a line captured from the user is up to 128 characters.
It can be assumed that complex, whole and rational numbers are not mixed
In rational numbers, only one digit should be displayed after the period
Coefficients of complex numbers are only integers. You can use the exercise in the .complex library
file names.
Ex3ql.c .1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

How can arrogance in an organization be combatted?

Answered: 1 week ago