The Way to Programming
The Way to Programming
First of all, thanks for taking the time to look at my post. I’m new to C programming in general, so i need a little help with some homework.
I have to first insert the number of rows and columns, then the elements and show the whole matrix. After that to arrange the columns in a mirror like way. For example,
If the matrix has 2 rows and 5 columns, it should look like this:
Matrix 1 2 3 4 5 6 7 8 9 0 Should become 5 4 3 2 1 0 9 8 7 6
First column changes places with the last. The second with the penultimate and so on.
I wrote half of the code. All i need now is a way to change the columns.
This is what i did so far:
#includevoid main() { int m, n, i, j, matrix[10][10]; printf("Insert the number of rows and columns:\n"); scanf("%d%d", &m, &n); printf("Insert the desired elements:\n"); for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) scanf("%d", &matrix[i][j]); printf("Your matrix has the following elements:\n"); for (i = 1; i <= m; i++) { for (j = 1 ; j <= n; j++) { printf("%d\t", matrix[i][j]); } printf("\n"); } }
Sign in to your account