#include <stdio.h>
void simetrica(int mat[][n], int n);
int main (void) {
int n=3;
int mat[n][n];
simetrica(mat,n);
}
void simetrica(int mat[][n], int n) {
int j;
int i;
for(i=0; i<n; i++){
for(j=0; j<n; j++){
mat[i][j]=(j+i);
}}
int cuenta=0;
for(i=0; i<n; i++){
for(j=0; j<n; j++){
if(mat[i][j]==mat[j][i]){
cuenta++;
}}}
if(cuenta==(n*n)){
printf("la matriz es simétrica");
}
else{
printf("La matriz no es simétrica");
}}
Also it's worth noting that the two occurrences of 'n' in the declaration:
void simetrica(int mat[][n], intn);
are completely separate and have a different meaning.
Here int mat[][n] n is a constant, known at compile time
whereas int n simply says the function will take an integer variable as its second parameter.
In fact, when declaring the constant as suggested above, constint n=3; // Use const to make it legal c++
the second parameter is no longer required, the function declaration can look like this:
void simetrica(int mat[][n]);
(remember to change the function definition to match).