0% found this document useful (0 votes)
9 views1 page

C Program for Matrix Determinant Calculation

The document contains C code for calculating the determinant of a matrix. It includes functions for determining the determinant, creating a submatrix, and calculating the sign based on the row index. The main function prompts the user for the size of the matrix and its elements, then displays the matrix and its determinant.

Uploaded by

Alan Uribe
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

C Program for Matrix Determinant Calculation

The document contains C code for calculating the determinant of a matrix. It includes functions for determining the determinant, creating a submatrix, and calculating the sign based on the row index. The main function prompts the user for the size of the matrix and its elements, then displays the matrix and its determinant.

Uploaded by

Alan Uribe
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include <stdio.

h> int determinante(int ** int ** subm(int k, int **


#include <stdlib.h> a, int tam){ a,int tam){
//PROTOTIPOS if (tam==1) int ** b;
int signo(int); return a[0][0]; int i,j;
int determinante(int ** if (tam==2) b=(int
,int); return a[0][0]*a[1][1]- **)malloc(sizeof(int
int ** subm(int , int ** , a[1][0]*a[0][1]; *)*tam);
int); int m=0; for (j=0;j<tam;j++)
main(){ int tam1=tam-1; b[j]=(int*)malloc(sizeof(i
int f,i,j; for (int i=0;i<tam;i++) nt)*tam);
int **pm; m=signo(i)*determinant
printf(“Da el tamaño de e(subm(i,a,tam1),tam1) for (i=0; i<tam;i++){
la matriz=>”); *a[0][i]+m; int m=0;
scanf(“%d”,&f); return m; for (j=0; j<tam+1;j++)
pm=(int } if (j != k){
**)malloc(sizeof(int b[i][m]=a[i+1][j];
*)*f); m++;
for (j=0;j<f;j++) }
pm[j]=(int*)malloc(sizeo }
f(int)*f); return b;
for (i=0;i<f;i++) }
for (j=0;j<f;j++){ int signo(int i){
printf(“a[%d][%d]=”,i,j); if (i%2==0)
scanf(“%d”,&pm[i][j]); return 1;
} return -1;
printf(“LA MATRIZ }
ES:\n”);
for (i=0;i<f;i++){
for (j=0;j<f;j++)
printf(“%d\t”,pm[i][j]);
putchar(‘\n’);
}
printf(“\nDeterminante(
A)=%d\n”,determinante
(pm,f));
getchar();
getchar();
}

You might also like