Look at your desired output. The forward diagonal starts at the last row of the array in the last position. Your example is a 5 element row so the forward diagonal starts at [0][0]. The next location is the previous row plus one more position since it is a diagonal. That would be [1][1]. Then [2][2], etc.
The reverse diagonal starts at [0][4] then advances to the next row less 1 more byte since the reverse diagonal retreats. That would be [1][3], [2][2], [3][1], and [4][0].
If you look at these indexes you can see a progression where you can use a loop counter to advance the rows plus another counter where you add 1 for the forward diagonal and subtract 1 for the reverse diagonal.
Your functions will need the address of the array, the number of rows and columns and maybe a toggle to tell the function to make the diagonal forwards or reverse. Maybe even another argument for the value to place in the diagonal positions.
The top line is simply places a zero in [0][0],[0][1], until you reach the end of the row.