Question

C++ Write a function that takes as an input parameter a matrix of integers, and 2...

C++

Write a function that takes as an input parameter a matrix of integers, and 2 integers representing the matrix’s dimensions. Print out the transposed version of the matrix.

Input:  [[1 2 3] 3,3 ->1 4 7
        [4 5 6]        2 5 8
        [7 8 9]]       3 6 9
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

#include <iostream>
using namespace std;
void printTranspose(int matrix[][3], int size1,int size2){
   for(int j=0;j<size2;j++){
       for(int i=0;i<size1;i++){
           cout<<matrix[i][j]<<" ";
       }
       cout<<endl;
   }
}

int main()
{
   int mat[3][3] = {
           {1,2,3},
           {4,5,6},
           {7,8,9}
   };

   printTranspose(mat,3,3);
   return 0;
}

output:

Add a comment
Know the answer?
Add Answer to:
C++ Write a function that takes as an input parameter a matrix of integers, and 2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in C++ please! Write a function that takes an array of integers as an input...

    Code in C++ please! Write a function that takes an array of integers as an input parameter (the address of the first value of the array). It returns nothing. It prints out the array as a single line, with commas between each number, and when the array is finished being printed, it prints an endl; so that we flush the buffer and move to a new line. (I’m having you write this function because you’ll be wanting to print out...

  • Write a C++ function that takes a pointer to an array of integers as a parameter...

    Write a C++ function that takes a pointer to an array of integers as a parameter and return the number of prime integers in the array. Write main() program to test the function.

  • Write a function named "find_value" that takes a key-value store as a parameter with strings as...

    Write a function named "find_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 4 is in the input as a value, false otherwise

  • C++ 2. (a) Write a function, printdixisors, that takes a single integer parameter and prints all...

    C++ 2. (a) Write a function, printdixisors, that takes a single integer parameter and prints all the numbers less that the parameter that are divisors of the parameter (i.e. divides it without a remainder) including 1. So printdivisors(6) will print 1,2,3. Note you may use a wrapper function or default parameters. (b) Write a function, sumdixisors, that takes a single integer parameter and returns the sum of all the divisors of the parameter (including 1). So sumdivisors(6) will return 6...

  • Write a function which takes as input a matrix and outputs a matrix in which each...

    Write a function which takes as input a matrix and outputs a matrix in which each positive element is doubled. For instance, for the matrix A=[3, -1; -2, 4], and output should be [6,-1; -2,8].

  • c++ Write a function Count_m_z that takes a string as an input parameter argument and counts...

    c++ Write a function Count_m_z that takes a string as an input parameter argument and counts the number of m, n, o, ... z characters in it. The function returns an integer value for the number of times those 14 lowercase letters appear in the input string. Your function should be named Count_m_z Your function should take one string parameter Your function should return the number of m, n, o, ... z characters as an integer Your function should not...

  • Question 5 (25 points): Write a function even() that takes in as a parameter a file...

    Question 5 (25 points): Write a function even() that takes in as a parameter a file name. The file name contains a list of integers, one on each line but there may be bad data. The function will return a list of all of the even numbers found in the file and should not crash if it encounters non-numeric input. The function should catch all file access and conversion errors (ValueError). Upload your test file to D2L. >>> print (even...

  • USING C++ and PYTHON Please Help me: 1. Write a function that takes in an array...

    USING C++ and PYTHON Please Help me: 1. Write a function that takes in an array of integers (and the size of the array in the C/C++ version). The function will reverse the array of integers and return the reversed array. Print the array that is returned from the function. How you "return" the array is up to you, but do not overwrite the original array. Note: in Python, the term list is more appropriate, see https://docs.python.org/3.5/tutorial/datastructures.html a) Example input:...

  • Write a function named "find_key" that takes a key-value store as a parameter with strings as...

    Write a function named "find_key" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the string "focus" is in the input as a key, false otherwise(javascript)

  • PYHTON Write a function which takes a single parameter. The parameter is a list of integers....

    PYHTON Write a function which takes a single parameter. The parameter is a list of integers. Your function should return a count of the number of integers in the list which are odd

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT