First off, you can seriously reduce the computation time for your program. For the first section of the function, since you are only making the swap when r==c, you can just use a single loop:
CODE
if (d=='l') {
for (int r=0; r<rows; r++) {
temp=y[r][r];
y[r][r]=y[f][r];
y[f][r]=temp;
}
}
since the cases where r!=c are just a waste of cpu time with the looping.
For swapping the right diagonal, you want to swap the element in (rows-r-1, c) with the element in (f,c). The extra -1 in there reflects the fact that your array of n elements has a maximum index of n-1. Therefore, using the same loop-collapsing optimization as above, you would need:
CODE
if (d=='r') {
for (int c=0; c<cols; c++) {
temp=y[cols-c-1][c];
y[cols-c-1][c]=y[f][c];
y[f][c]=temp;
}
}
And you should probably consider loading the matrix from a file or generate it automatically for your tests, since entering 200 elements by hand each time you want to test your code would be a bit of a tedious process.
Hope that helps,
-jjh