. (Diagonal matrix) • Assume that a sequence of n numbers is given. • Convert the sequence (1-D array) to an n x n diago
Posted: Fri May 20, 2022 12:24 pm
matrix
. (Diagonal matrix) • Assume that a sequence of n numbers is given. • Convert the sequence (1-D array) to an n x n diagonal matrix (2-D array) where the diagonal entries are the sequence. 1 0 0 0 1 1 -2 3 3 -2 -4 0 0 0 0 0 3 1:18 0 0 0 -4
• Program setup 1) Ask the user to enter a sequence of n = 4 elements (float), and store them in an array a. 2) Implement a function that creates a 2-D array (n x n) where the diagonal entries are the sequence a. 3) Display the diagonal matrix. The prototypes of the functions are as follows. - void diag(float a[], float diag_a[][LEN], int len); - void mat_print(float diag_a[LEN][LEN], int len);