in-memory transposing of a rectangular array

I was asked this question in an interview. Am looking for answers for this:

A rectangular array of cells (say m*n) are selected in a spreadsheet (eg: MS excel). Assume that the cells contain only integer values. They need to be pasted to some location within the same spreadsheet after transposing the array (which means that the destination location will have transposed array containing n*m cells). We cannot use any memory buffers (eg: clipboard) to perform this operation. We can only use one or two temporary integer variables if required.
Write a C function/algorithm to do the same.
I'll really appreciate if someone can help me on this. Remember that some (or all) cells at the paste location might overlap with the copied (source) cells.

If you are allowed to use two temporary integer variables, then use both. Have one variable,VAL, that stores the value of one single cell at any given time. Have the other variable, LOC, store the location in the spreadsheet. I.e. if you have already moved 27 cells than LOC = 28. You will increment LOC each time a value is stored in the new spreadsheet, not each time a value is stored in VAL. This will tell you where to get the next value from and where to place it. Then, each time LOC % n == 0 you will want to move down to the next row of the spreadsheet. Let me know if you want more detail.

Let me clarify my query.
I'm not looking for code for this problem. I said 'Write a C function/algorithm to do the same' in my original post, because I was quoting the exact problem statement (as asked by the interviewer).
I pretty well know the logic (and code) for transposing a rectangular matrix in-memory. The only thing I need help for is how to take care of overlapping cells in this copy-paste operation. The transpose program is quite straight-forward but we've to ensure that no data-loss happens while doing this. So, any tips regarding that are welcome. No need to give any code.

Let me clarify my query.
I'm not looking for code for this problem. I said 'Write a C function/algorithm to do the same' in my original post, because I was quoting the exact problem statement (as asked by the interviewer).
I pretty well know the logic (and code) for transposing a rectangular matrix in-memory. The only thing I need help for is how to take care of overlapping cells in this copy-paste operation. The transpose program is quite straight-forward but we've to ensure that no data-loss happens while doing this. So, any tips regarding that are welcome. No need to give any code.

thanks!

Absolutely none of this information was apparent in your first post. Be sure you give all necessary information the first time.

No programmer worth his salt would waste his company's time on some trivia like this. Yes, it is possible to do an overlapped transpose and paste without using extra memory, but there is no need. Can you really believe anyone to be using your spreadsheet on a system so limited in resources that it can't duplicate itself? Access itself wouldn't run.

Just allocate memory for the transposed array, transpose into it, copy it back in the new location (possibly overlapped), and free the memory. Anything more than that is not cost-effective, sure to be error prone (especially when other people start messing with it), and a maintenance nightmare. Keep code simple.

So, to reiterate, writing specialized cases is a waste of time (money) and resources (money) in development, production, and maintenance when there is no quantifiable gain in function, speed, use of target system resources, and/or etc.

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...