Post

The Last day of 2023

As the year comes to an end with only 76 more years until the next century, I was immersed in the task of organizing, relocating, and deleting data from my drive, as I had nothing better to do, and taking a stroll down memory lane as I did so. Amidst this process, I uncovered a piece of code, possibly from a past assignment.

Much like fellow programmers worldwide, I fondly recall the joyful moments of executing the classic "Hello World" code in various programming languages. Witnessing the output of "Hello World" is an immensely gratifying experience, which is still vividly imprinted in my mind. .

As I reflect on these memories and reminisce about my early days of falling in love with coding, I realize how far I've come. A key realization before the start of the new year is the importance of consistently working and improving on things we are passionate about, and eventually things fall into place.

The code I stumbled upon deals with swapping the rows and columns of a matrix of any dimension, and I know it is long and unoptimized but I am proud of my rookie days, the stepping stones of my life.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>

int main() {
    int row127, col127, temp;
    printf("Enter the row and Column of the matrix: ");
    scanf("%d %d", &row127, &col127);
    int A[row127][col127], copy[row127][col127];

    for (int i = 0; i<row127; i++) 
            {
                for (int j = 0; j<col127; j++)
                    {
                        printf("Enter the Element (%d,%d): ", i+1, j+1);
                        scanf("%d", &A[i][j]);
                    }
            }

    //making a copy of the element
    for (int i = 0; i<row127; i++) 
            {
                for (int j = 0; j<col127; j++)
                    {
                        copy[i][j] = A[i][j];
                    }
            }

    printf("\nInitial Matrix\n");
    for (int i = 0; i<row127; i++) 
            {
                for (int j = 0; j<col127; j++)
                    {
                        printf("%d\t", A[i][j]);
                    }
                printf("\n");
            }

    for (int i = 0; i<row127/2; i++) {
        for (int j = 0; j<col127; j++) {
            temp = A[i][j];
            A[i][j] = A[row127-i-1][j];
            A[row127-i-1][j] = temp;
        }
    }
    printf("\nArray after Swapping the Rows: \n");
    for (int i = 0; i<row127; i++) {
        for (int j = 0; j<col127; j++) {
            printf("%d ", A[i][j]);
        }
        printf("\n");
    }
    for (int i = 0; i<col127/2; i++) {
        for (int j = 0; j<row127; j++) {
            temp = copy[j][i];
            copy[j][i] = copy[j][col127-i-1];
            copy[j][col127-i-1] = temp;
        }
    }

    printf("\nArray After Swapping the columns: \n");
    for (int i = 0; i<row127; i++) {
        for (int j = 0; j<col127; j++) {
            printf("%d ", copy[i][j]);
        }
        printf("\n");
    }   
    return 0;
}
This post is licensed under CC BY 4.0 by the author.