For diagonal difference this logic is showing a garbage value. Where am I doing wrong?
int main()
{
int i,a[3][3];
int diagonal_diff;
int lsum=0,rsum=0;
for(i=0;i3;i++){
lsum=lsum+a[i][i];
rsum=rsum+a[i][2-i];
}
diagonal_diff= abs(lsum-rsum);
printf("%d",diagonal_diff);
}
Topic c
Category Data Science