I am trying to see if a 4x4 matrix is symmetric, and below is what i have so far. Upon compiling I receive the message:
pExam3p2.c:12:13: warning: expression result unused [-Wunused-value]
if (Num[r,c]==Num[c,r]){
^
pExam3p2.c:12:23: warning: expression result unused [-Wunused-value]
if (Num[r,c]==Num[c,r]).
I thought that adding an else statement would resolve this issue. But it does not. Any ideas is greatly appreciated. Thank you!
#include <stdio.h>
char isSymm (int Num[][4], int rows, int cols){
int r,c, count=0;
for (r=0; r<rows; r++){
for (c=0; c<cols; c++){
if (Num[r,c]==Num[c,r]){
count=count+1;
}
else{
count=count;
}
}
}
if (count==16){
return 'y';
}
else {
return 'n';
}
}
int main (void){
int Num[4][4];
int c;
int r;
int size =4;
for (r=0;r<size; r++){
for (c=0; c<size; c++){
printf("Enter your number: ");
scanf("%d", &Num[r][c]); //NOTE THE &...
}
}
char result= isSymm(Num, 4, 4);
printf("%c", result);
}