Expected output not coming if a Non Square Matrix is taken as input

Actually the problem arises when I take a non square matrix as an input and as the condition of transpose is given as if(i<j){ swap(a[i][j] , a[j][i]) }

But in a non square matrix some rows are left out due to this condition.

What can I do for this?

Save your code on ide.codingblocks.com and share its link.

here is the link to my code

Refer this

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.