Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that will transpose a square matrix. For example, a 3 x 3 matrix, say A, contains the 9 numbers as follows:

Write a C program that will transpose a square matrix.

For example, a 3 x 3 matrix, say A, contains the 9 numbers as follows:

1 2 3

4 5 6

7 8 9

The transpose of this matrix is

1 4 7

2 5 8

3 6 0

Complete this code below :

#include void swap( int *a, int *b ) {

/* INSERT CODE HERE */

return ;

}

void transpose( int A[][3], int r, int c ) {

/* INSERT CODE HERE. */

return ;

}

int main( int argc, char *argv[] ) {

int A[3][3] = { { 1, 2, 3 }, { 4, 5, 6 } , {7, 8, 9} } ;

int i, j ;

transpose( A, 3 , 3 ) ; for ( i = 0 ; i < 3 ; i++ ) {

for ( j = 0 ; j < 3 ; j++ )

printf( "%4d", A[i][j] ) ;

printf( " " ) ;

}

return 0 ;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions