Arrays

This is a discussion on Arrays within the C Programming forums, part of the General Programming Boards category; if we declare: int a[4][3]; then a[i][j] is equalivent to: 1. *(a[i]+j) 2. *(&a[0][0]+4*i+j) 3. Both 1 and 2 4. ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    2

    Arrays

    if we declare: int a[4][3]; then a[i][j] is equalivent to:

    1. *(a[i]+j)
    2. *(&a[0][0]+4*i+j)
    3. Both 1 and 2
    4. none of the above.

    Please assist in this question

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Try compiling each one of those and see what happens.

  3. #3
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by guoer View Post
    if we declare: int a[4][3]; then a[i][j] is equalivent to:

    1. *(a[i]+j)
    2. *(&a[0][0]+4*i+j)
    3. Both 1 and 2
    4. none of the above.

    Please assist in this question
    Do your own homework!

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    2
    Could any expert kindly assist? Or should i say the question is too hard to the experts over here?

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,598
    Quote Originally Posted by guoer
    Could any expert kindly assist? Or should i say the question is too hard to the experts over here?
    Read about the homework policy. It does not take an expert to answer your question correctly.

    Take this as an unofficial warning: do not try emotional blackmail by implying that if we do not spoonfeed you the answer, we must be incompetent.
    Last edited by laserlight; 02-27-2009 at 04:02 AM. Reason: Might as well delete pic-o-matic's post since matsp has a better and yet non-obvious answer.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by guoer View Post
    Could any expert kindly assist? Or should i say the question is too hard to the experts over here?
    No, it is a case of : You figure out what it does, and then we can either EXPLAIN why it is that way, or tell you where you went wrong, if you get it wrong. It is not "ask a question and get the answer", when the actual purpose of the question itself is that you should learn something.

    And just so that we can rule out that I'm waiting for your input to know the answer, here's the answer encrypted:
    Where n is the question number, x = correct answer:
    Code:
    x = (8 >> (n+2));
    --
    Mats
    Last edited by matsp; 02-27-2009 at 04:00 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 06:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 03:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21