You are viewing a single comment's thread. Return to all comments →
int sum1=0,sum2=0; for(int i=0, k=size-1; i< size; i++){ for(int j=0; j< size; j++){ cin >> matrix[i][j]; if(i==j) sum1 += matrix[i][j]; } sum2 += matrix[i][k]; k -= 1; } cout << abs(sum1-sum2);
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →