• C

matrix handling function

how to determine the transpose and inverse of a matrix A and Matrix B using C language
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

latinoAuthor Commented:
It depends on the dimension of the matrix, because there exists
different algorithm. If you are interessted in such codes use
the book Numerical Recipes for C.
latinoAuthor Commented:
I need some help about this online so if any info let me know
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Pls tell my what is the dimension of the matrix, is it a sparse matrix, ... This information is needed to determine which algorithm you should use.

to do this you Dynamically allocate and then perform whatever operation you need using the operator [].
the example below transpotse a matrix of n,m dimention.

#include <conio.h>
#include <Stdio.h>
#include <alloc.h>

void getinput ( int **ArrayPtr , int raws , int cols );
int **transpose( int **ArrayPtr , int raws , int cols );
void display( int **ArrayPtr ,int raws ,int cols );

void main()
 int **ArrayIn;
 int raws,cols;
 int i,j;


 printf("Enter Number Of Raws : ");       //Get Array Dimentions
 scanf("%d", &raws );
 printf("Enter Number Of Columns : ");
 scanf("%d", &cols );

 ArrayIn = calloc ( raws , sizeof(int *) );     //Dynamically Allocate The Array
 for ( j=0 ; j<raws ;j++ ){
     ArrayIn[j] = calloc( cols, sizeof(int) );

 getinput( ArrayIn ,raws ,cols );      // Get the Array

 ArrayIn=transpose(ArrayIn ,raws,cols);            //Transpose the Array

 display(ArrayIn , raws , cols);          // Display After Transpose



void getinput ( int **ArrayPtr , int raws , int cols ){
int i,j;

 for( j=0 ; j<raws ;j++ ){
     for( i=0 ; i<cols ; i++ ){
       printf("Enter Element #%d%d : ",j,i);
int **transpose( int **ArrayPtr , int raws , int cols ){
 int **trans;
 int i,j;

 trans = calloc ( cols , sizeof(int *) ); // Allocate Transpose Array
 for ( j=0 ; j<cols ;j++ ){
     trans[j] = calloc( raws, sizeof(int) );

 for( j=0 ; j<raws ;j++ ){
     for( i=0 ; i<cols ; i++ ){

 return (trans);

void display( int **ArrayPtr ,int raws , int cols ){
 int i,j;

 for( j=0 ; j<cols ;j++ ){
     for( i=0 ; i<raws ; i++ ){
       printf("#%d%d = %d  |",j,i,ArrayPtr[j][i]);


likewise you could do any operation you need by using a similar algorithm.

E-mail me at : hbadr@mailcity.com

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.