Code giving wrong output

So, the code that is explained in the video is giving a wrong output in case of 4by5 matrix

The output is 12 13 in end whereas it should be 13 12. I have used the same code that is given in video, can you please help me out.
This problem is occurring after taking care of the corner cases.

can you plz share the link of your code?
i will check

Link of Code: https://goonlinetools.com/snapshot/code/#julb2q4i0adk0dtzh5aem

if(endCol > startCol)
here use equal to also
if(endCol >= startCol)

here is modified Code