Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that transposes a matrix A and displays the result on the screen | Transpose of a Matrix.

Posted on February 5, 2022February 5, 2022 By myustaadg.com
Spread the love

Write a program that transposes a matrix A and displays result on the screen.
Note: A matrix which is obtained by the interchanging of rows and columns of a matrix is called the transpose of given matrix and is denoted by At.

So let’s Write Code:

Introduction to C++ Programming | Download and Install Dev C++ Compiler
Write a program that transposes a matrix A and displays the result on the screen | Transpose of a Matrix.
#include<iostream.h>
using namespace std;
void transpose(int [2][4], int [4][2]);
void print(char [25], int [4][2]);
main()
{
int A[2][4]={{24,31,18,51},{4,15,13,2}};
int T[4][2];
char str[25];
cout<<endl<<"Matrix A:"<<endl;
for(int r = 0; r<=1; r++)
{
for(int c = 0; c<=3; c++)
cout<<A[r][c]<<"\t";
cout<<endl;
}
transpose(A, T);
print("Transpose of A: ",T);

}
// definition of transpose() function
void transpose(int X[2][4], int Y[4][2])
{
int r, c;
for(r = 0; r<=1; r++)
for(c = 0; c<=3; c++)
Y[c][r] = X[r][c];
}

void print(char str[], int R[4][2])
{
int r, c;
cout<<endl<<str<<endl;
for(r = 0; r<=3; r++)
{
for(c = 0; c<=1; c++)
cout<<R[r][c]<<"\t";
cout<<endl;
}
}

Hope You will learn Something. Happy Coding.

Visit my YouTube Channel as Well๐Ÿ˜‡ https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

Click on the below Links for more Programming Exercises:

Conditional Structure Exercises: ๐Ÿ‘‰https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

Array Exercises: ๐Ÿ‘‰https://myustaadg.com/category/programming-exercises/arrays-exercises/

Arrays Exercises, Programming Exercises Tags:array in programing, Array simple codes, Arrays, arrays C++ codes, arrays C++ programing exercises, arrays codes, Arrays exercises, Arrays full course, arrays in programing, Write a program that transposes a matrix A and displays the result on the screen | Transpose of a Matrix.

Post navigation

Previous Post: Write a program that inputs values into a one-dimensional array of ten elements. Draws a bar chart or histogram.
Next Post: Write a program to initialize values in two tables A and B. Multiply matrix A and B and store results into table C | Multiplication of matrices.

More Related Articles

Write a program that inputs ten values in an array and calculates the sum of these values. Arrays Exercises
Write a program to input an array of 10 elements from the user and count the number of odd numbers and display it. Arrays Exercises
Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen. Arrays Exercises
Write a program that inputs marks of N students and finds out the grade of each student. Arrays Exercises
Write a program which input age from user and display on the screen if he/she is of legal age or not | Python Programming Programming Exercises
Write a program that inputs values into a one-dimensional array and finds odd and even Numbers. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme