Results 1 to 2 of 2

Thread: aptitude question?

  1. #1
    Join Date
    May 2007
    Posts
    1

    Default aptitude question?

    In a two-dimensional array, X (9, 7), with each element occupying 4 bytes of memory, with the address of the first element X (1, 1) is 3000, find the address of X (8, 5). please explain how the answer is obtained

  2. #2
    Join Date
    May 2007
    Posts
    1

    Default

    addressof(x(8,5))=3000+9*8*4+5*4=3000+288+20=3248e xplanation of numbers:3000 = starting point9 = Dimension-1 subscript (+1 assumes lbound is 0)8 = size allocated for second dimension4 = data type size5 = dimension-2 subscript4 = data type sizeBasically the two-dimensional array is laid out one-dimensionally, and each time you ++ the first dimension, you're in effect counting forward the size of the second dimension in the array.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •