arrays-2d

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eesha
    New Member
    • Sep 2006
    • 1

    #1

    arrays-2d

    I wanna ask answer to this question

    a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

    please answer this question as soon as possible.....
  • nikhilraj
    New Member
    • Sep 2006
    • 11

    #2
    Originally posted by eesha
    I wanna ask answer to this question

    a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

    please answer this question as soon as possible.....



    int occupies two bytes in c so here in ur query if a[1][1] is stored in then a[1][2] occupies 3002 a[1][2] is stored in 3004 like this u can go on calculating n u will get the answer

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Originally posted by nikhilraj
      int occupies two bytes in c
      This is factually incorrect, on some platforms an int is 2 bytes many platforms today int is 4 bytes.

      On many platforms today short is 2 bytes but c does not guarantee that all c guarantees about variable size is that

      sizeof(char) == 1

      sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

      Comment

      • mrscript
        New Member
        • Sep 2006
        • 2

        #4
        Originally posted by Banfa
        This is factually incorrect, on some platforms an int is 2 bytes many platforms today int is 4 bytes.

        On many platforms today short is 2 bytes but c does not guarantee that all c guarantees about variable size is that

        sizeof(char) == 1

        sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

        It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.

        Comment

        • mrscript
          New Member
          • Sep 2006
          • 2

          #5
          Originally posted by eesha
          I wanna ask answer to this question

          a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

          please answer this question as soon as possible.....

          It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Originally posted by mrscript
            It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.
            It does depend on the machines nature but it is not limited to those values you give.

            As far as the C standard is concerned an int can be on any byte size from 1 - infinity and the number of bits in a byte can be any number from 1 - infinity.

            Comment

            Working...