 # Operations on square matrices. Complete the following C program: #...

## Question

Operations on square matrices. Complete the following C program:
#include <stdio .h>
#define MAXN 20
void print mat (double mat[MAXN] [MAXN] , int n );
void init mat (double mat[MAXN] [MAXN] , int n );
void read mat (double mat[MAXN] [MAXN] , int ∗n );
void print row sums (double mat[MAXN] [MAXN] , int n );
void print diagonal (double mat[MAXN] [MAXN] , int n );
double minimum(double mat[MAXN] [MAXN], int n);
int main(void){ int sz1 , sz2 ;
double mat[MAXN] [MAXN] ;
sz1 = 3;
init mat (mat, sz1 ); int n );
print mat (mat, sz1 );
print row sums (mat, sz1 );
print diagonal (mat, sz1 );
printf (”The minimum of all elements is %8.2 l f \n” , minimum(mat, sz1 ));
// test 2
read mat (mat,&sz2 );
print mat (mat, sz2 );
print row sums (mat, sz2 );
print diagonal (mat, sz2 );
printf (”The minimum of all elements is %8.2 l f \n” , minimum(mat, sz2 ));
}
The following functions must be written:
(a) void print mat(double mat[MAX N][MAX N], int n) — print the matrix one row per line. Print two decimal place for each number.
(b) void init mat(double mat[MAX N][MAXN], int n) — initialize the matrix with the numbers 1.0,2.0,...,n × n.
(c) void read mat(double mat[MAX N][MAXN], ?? n) — read the number of rows n, followed by n × n double values. The values are presented one row per line. Please fill in the type of n.

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

void read_mat ( double mat [MAX_N] [MAX_N] , int * n ){
int i;
int j;
double temp;
int size;

// read the number of rows n
scanf("%d", n);

// to make sure that the program won't be overflowed
size = *n <= MAX_N ? *n : MAX_N;
// read n * n double values
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
scanf("%lf", &temp);
mat[i][j] = temp;
}
}...

By purchasing this solution you'll be able to access the following files:
Solution.c.

\$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.