My code is same as the code in video but it is not giving correct o/p

void rotate(int arr[][100],int n){
// To reverse the array.
for(int row = 0;row<n;row++){
int start_col = 0;
int end_col = n-1;
while(start_col < end_col){
swap(arr[row][start_col],arr[row][end_col]);
start_col++;
end_col–;
}
}

// To take transpose.
for(int i = 0 ; i < n; i++){
for ( int j = 0 ; j < n;j++){
if (i < j){
swap(arr[i][j],arr[j][i]);
}
}
}

//output
for(int i = 0 ; i < n; i++){
for ( int j = 0 ; j < n;j++){
cout<<arr[i][j]<<" ";

	}
	cout<<endl;
}

}

hi @vaibhave31,
the code was correct only u may be confused in clockwise or anti clock wise direction , ive added both the senario there and commented out

the question in the challenge section has anticlock wise printing as well as in this vid

https://ide.codingblocks.com/s/658308 please check this

@vaibhave31
is the issue resolved?

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.