We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Try writing a matrix in a paper and also give values to i,j,k as given above. You will understand why we need "k" much better that way, than just reading the code.

## Diagonal Difference

You are viewing a single comment's thread. Return to all comments →

Really nice one.

You can actually move up the k -= 1 into the outer loop next to the i++ as:

Yes, thanks!

what's the use of k here?? k=size-1...and k-- ? can Anyone help out..please

Try writing a matrix in a paper and also give values to i,j,k as given above. You will understand why we need "k" much better that way, than just reading the code.

yes I dont get k? i reprents rows,j represents columns i think but k?

well you can use i in place of k that's not a problem that's just a variable used for looping

Here is the video explaination- https://youtu.be/f6bTIsj9ne8