Arrays: two-dimensional arrays initialization and usage

supriyo_biswas · updated April 11, 2020
#include <stdio.h>

int main() {
    // declare an array
    int a[2][2];

    // perform a few operations
    a[0][0] = 10;
    a[0][1] = a[0][0] * 10;
    a[1][0] = a[0][1] / 5;
    a[1][1] = a[0][1] + a[1][0];

    // print the array
    printf("%d %d\n", a[0][0], a[0][1]);
    printf("%d %d\n", a[1][0], a[1][1]);

    return 0;
}
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.