Book Your slot
X
ONLINE BOOKING
BOOK NOW
OFFLINE BOOKING
Call or WhatsApp 7993732682 (WhatsApp Now), 9177341827 (WhatsApp Now)
search
Menu Login home
  • Questions

  • Library

  • University Updates

  • Informatives

  • Technology Lines

  • Training & Internships

  • X
    Menu
  • Home
  • Privacy Policy
  • Legal Disclaimer
  • Terms & Conditions
  • Return Policy
  • About Us
  • Need any help?? write to us at

    support@engineershub.co

    Follow Us

    X
    LOGIN
    Login to access posts, links, updates, question papers, materials, one liners!
    Use Your Email Address/Mobile and Password to Login
    Forgot Password?
    Not a member? Sign Up
    LOGIN WITH EMAIL/MOBILE
    Forgot Password?
    Go Back
    FORGOT PASSWORD
    Go Back
    RESET PASSWORD
    Go Back
    Continue with LinkedIn
    OR
    Fill Up a Simple Form
    Already a Member? Login
    SIGN UP
    Fill all the below details correctly and click on Next
    Go Back
    Define multi-dimensional arrays? How to declare multi-dimensional arrays? - EngineersHub
    Go Back
    Question
    Arunbavu Arun
    3 years ago
    1 Answer(s) posted Write an answer 8133
    Answer
    Read Mode
    Answer posted by Anvesh Kanchibhotla
    3 years ago

    Multidimensional arrays are often known as an array of arrays. In multidimensional arrays, the array is divided into rows and columns, mainly while considering multidimensional arrays we will be discussing mainly about two-dimensional arrays and a bit about three-dimensional arrays.

    Syntax: data_type array_name[size1][size2][size3]------[sizeN];

    In 2-D array we can declare an array as :

    int arr[3][3] = { 1, 2, 3,

                           4, 5, 6,

                          7, 8, 9

                     };

    where the first index value shows the number of the rows and the second index value shows the number of the columns in the array. To access the various elements in a 2-D array we can use:

    printf("%d", a[2][3]);

    /* output will be 6, as a[2][3] means the third element of the second row of the array */

    In 3-D we can declare the array in the following manner :

    int arr[3][3][3] =

    { 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

      };

    /* here we have divided array into the grid for sake of convenience as in above declaration we have created 3 different grids, each has rows and columns */

    If we want to access the element in a 3-D array we can do it as follows :

    printf("%d",a[2][2][2]);

    /* its output will be 26, as a[2][2][2] means first value in [ ] corresponds to the grid no. i.e. 3 and the second value in [ ] means the third row in the corresponding grid and last [ ] means the third column */

    Ex:- int arr[3][5][12];

                     float table[5][4][5][3];

    arr is a 3D array declared to contain 180 (3*5*12) int type elements. Similarly, the table is a 4D array containing 300 elements of float type.

    Users Joined

    mahek thakur
    8 months ago
    sowmya
    8 months ago
    biraja
    8 months ago
    Diana R
    9 months ago
    P Annapoorani
    9 months ago
    X
    Define multi-dimensional arrays? How to declare multi-dimensional arrays?
    X
    Define multi-dimensional arrays? How to declare multi-dimensional arrays?

    Multidimensional arrays are often known as an array of arrays. In multidimensional arrays, the array is divided into rows and columns, mainly while considering multidimensional arrays we will be discussing mainly about two-dimensional arrays and a bit about three-dimensional arrays.

    Syntax: data_type array_name[size1][size2][size3]------[sizeN];

    In 2-D array we can declare an array as :

    int arr[3][3] = { 1, 2, 3,

                           4, 5, 6,

                          7, 8, 9

                     };

    where the first index value shows the number of the rows and the second index value shows the number of the columns in the array. To access the various elements in a 2-D array we can use:

    printf("%d", a[2][3]);

    /* output will be 6, as a[2][3] means the third element of the second row of the array */

    In 3-D we can declare the array in the following manner :

    int arr[3][3][3] =

    { 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

      };

    /* here we have divided array into the grid for sake of convenience as in above declaration we have created 3 different grids, each has rows and columns */

    If we want to access the element in a 3-D array we can do it as follows :

    printf("%d",a[2][2][2]);

    /* its output will be 26, as a[2][2][2] means first value in [ ] corresponds to the grid no. i.e. 3 and the second value in [ ] means the third row in the corresponding grid and last [ ] means the third column */

    Ex:- int arr[3][5][12];

                     float table[5][4][5][3];

    arr is a 3D array declared to contain 180 (3*5*12) int type elements. Similarly, the table is a 4D array containing 300 elements of float type.

    EngineersHub Logo
    x
    Loading...