Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 12E
A matrix M with i rows, j columns can be transposed into a matrix N having j rows and i columns by simply setting the value of Na,b equal to the value of Mb,a for all relevant values of a and b.
- a. Write a function t that takes as an argument a 4 × 5 matrix and a 5 × 4 matrix. Have the function transpose the 4 × 5 matrix and store the results in the 5 × 4 matrix. Also write a m routine to test the function.
- b. Using variable-length arrays, rewrite the t function developed in exercise 12a to take the number of rows and columns as arguments, and to transpose the matrix of the specified dimensions.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C'ZT
Write a function that takes one input, a matrix X. Your function should modify X and return the modified version of X as an output. Assuming that X
has m rows and n columns:
When m is equal to n, modified X should be the same as X.
When m is greater than n, the modified version of X should be m x m. New columns should be added to the right of the original columns of X, with
each new element having a value that is one less than the element in the column to the left. For example, the matrix:
2 3
4 6
Would become:
2321
4 65 4
8987
1210
When n is greater than m, the modified version of X should be n x n. New rows should be added to the bottom of the original rows of X, with each new
element having a value that is one more than the element in the row above it. For example, the matrix:
2345
468 10
Would become
2345
4 6 1e
3791L
G8 10 12
A matrix M with
i
rows,
j
columns can be transposed into a matrix N having
j
rows and
i
columns by simply setting the value of N
a,b
equal to the value of M
b,a
for all relevant values
of a and b.
a.
Write a function trasposeMatrix() that takes as an argument a 4 x 5 matrix and a 5 x 4
matrix. Have the function transpose the 4 x 5 matrix and store the results in the 5 x 4
matrix. Also write a main() to test the function.
b.
Using variable-length arrays, rewrite the transportMatrix() function developed in a. to
take the number of rows and columns as arguments, and to transpose the matrix of the
specified dimension
This is not a graded question so please don't disregard it as if it is. Thank you in advance professor!
Chapter 7 Solutions
Programming in C
Ch. 7 - Type in and run the 17 programs presented in this...Ch. 7 - Prob. 2ECh. 7 - Modify Program 7.8 so that the value of e is...Ch. 7 - Modify Program 7.8 so that the value of g is...Ch. 7 - Prob. 6ECh. 7 - Write a function that raises an integer to a...Ch. 7 - Prob. 8ECh. 7 - The least common multiple (1cm) of two positive...Ch. 7 - Prob. 10ECh. 7 - Write a function called a that takes two...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The following hands-on exercises develop additional techniques for manipulating and
accessing controls placed o...
Introduction To Programming Using Visual Basic (11th Edition)
A (n) _______operator determines if a specific relationship exists between two values.
Starting Out With Visual Basic (7th Edition)
Compare the method headers of getPrice and printTicket in Code 2.1. Apart from their names, what is the main di...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Suppose that a 2 MB file consisting of 512-byte logical blocks is stored on a disk drive with the following cha...
Computer Systems: A Programmer's Perspective (3rd Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Suppose the Vole communicates with a printer using the technique of memory-mapped I/O. Suppose also that addres...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- R Programming - Rmarkdown: 1. Given two vectors x and y of equal length, in one line of code (in the function body), write a function find_max_logical() that will output a single logical vector that is TRUE at the indices where the maximum values in x and y are. For example, given the below vectors: x <- c(Inf, 3, 2, 6, 99) y <- c(12, 1, 0, 40, 5) # You should return (without manually creating the vector with c()) c(TRUE, FALSE, FALSE, TRUE, FALSE) # Noting that Inf and 40 are the max values of x and y respectively, ## at the 1st index of x and the 4th index of y. Please test your functions on the following test inputs in your submission: # test case 1: x = c(Inf, 3, 2, 6, 99), y = c(12, 1, 0, 40, 5) # test case 2: x = 1:5, y = 1:5 # test case 3: x = c(1, 4, 9), y = c(1, 4, 2)arrow_forward1. Write a function (call it mylm) that takes two inputs: a vector y of n elements and a matrix X of n times k elements, where n should be greater than k, and returns three outputs: bhat = solve(X'X)X'y, X'X and X'y (the prime symbol means transpose). Use the attr method to return the second and third outputs. Note that you do not need to specify values for y and X when you write this function.arrow_forwardWrite a R function that takes two inputs: a vector y of n elements and a matrix X of n times k elements, where n should be greater than k, and returns two outputs: $X'X$ and $X'y$. Use the attr method to return the second output.arrow_forward
- Write a function NewArray.m which takes two input arguments, m and n, and returns one output argument, A. The matrix A must have m rows and n columns. Create a (nested) for loop which computes A such that aij = = -i+j³. You must use a for loop for full credit. 022 wbsafa@ffalo.edustuse rate 9:19 PM EDT Вс C For example, if m= 2 and n = 3, then A= ck control ! 1 FI BO Q A @ 2 N 2 option F2 W S # 3 80 F3 X E H command D $ 4 a C R LL % 5 F + FS T V MacBook Air 6 G F6 tv 9 Y B & 7 H 1 6 25/ 34 U N 8 25). J F I ( 9 M K ** O ) 0 command : . ; F I { - [ 11 ? option 1 . I 1 delarrow_forwardLanguage: Python Make a function and after that please test it on a paper by making 8 by 8 queens board.arrow_forward2) Let multidimensional array with size 3 x 4 be a {1,2,3,4,5,6,7,8,9,10,11,12} and b be the last digit of your student number. Accordingly, if we run the given functions in the following order, what will be the output? Explain step by step. b= 5 function1(b); print(A,b); function2(A,b); print(A, b); function3(A[b%4][b%3],b); print(A,b); void print(int a(][3],int b){ printf("\nb=%d",b); for(int i=0;i<4;i++}{ printf("\n"); for(int j=0;j<3;j++}{ printf("%3d",a[i][]); } void function1(int a)}{ a=a+2; void function2(int A[][3],int b){ for(int j=0;j<3;j++){ A[2]]=A[2][i]+b; } void function3(int a,int b){ a=a+b;arrow_forward
- Please send me answer of this question immediately and i will give you like sure sirarrow_forwardPerform matrix multiplication of 2D array. The program should meet the matrix multiplication rule i.e. number of columns of first matrix should be equal to the number of rows of second matrix. The input of two matrices A and B is given by user. Use function approach to handle array multiplication.arrow_forwardThis is not a graded question so please don't disregard it as if it is.Thank you in advance professor!arrow_forward
- This is not a graded question so please don't disregard it as if it is. Thank you in advance professor!arrow_forwardIn Python Pleasearrow_forwardWrite a function that takes a vector of integers as an argument and returns a new vector with the same elements as the input vector, but with all odd elements replaced by their square root and all even elements replaced by their square. The function should use a loop and the modulo operator to determine whether an element is odd or even. To solve this problem, you will need to use a loop to iterate over the elements of the input vector, use the modulo operator to determine whether each element is odd or even, and use an if-else statement to determine what action to take for each element. This question requires knowledge of loops, the modulo operator, and if-else statements in R. It is a relatively advanced question and may be challenging for those who are not familiar with these concepts.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License