Is this correct way to do this?

So, in the video of the Rotate image, sir has used the swap inbuilt function to make that code work…
and I have done it differently is this way considered correct?
the thing that I applied in my code is when we are rotating a matrix its last column becomes the first row of output
so I added a loop and decreased the value of the previous column until it becomes zero and prints it as the rows

can you please share you code in text format so that it will essay to debug .

#include using namespace std; void rotate(int arr[][100],int row,int col){ int sr = 0; int er = row-1; int sc = 0; int ec = col-1; while(ec>=0){ for(int i = sr;i<=col-1;i++){ cout<<arr[i][ec]<<" "; } ec–; cout<<endl;} } int main(){ int row; int col = 0; cout<<"Enter row : "; cin>>row; col = row; int arr[100][100]; for(int i=0;i<row;i++){ for(int j=0;j<col;j++){ cin>>arr[i][j]; } } rotate(arr,row,col); }

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.