Thread: Array Doubt

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by shyjuu View Post
    I surely want to work out by my own so I am putting so much efforts on clearing my doubts
    Study the wonderful C Tutorial linked at the top of this forum. It has all the info you will need for a much better understanding of C - including C array declaration syntax.

  2. #17
    Registered User
    Join Date
    Jul 2010
    Posts
    47
    Quote Originally Posted by Adak View Post
    Study the wonderful C Tutorial linked at the top of this forum. It has all the info you will need for a much better understanding of C - including C array declaration syntax.
    I already know the syntax, but in this question I am not getting

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If you don't understand the question, then ask your instructor for clarification.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    Registered User
    Join Date
    Jul 2010
    Posts
    47
    Quote Originally Posted by laserlight View Post
    If you don't understand the question, then ask your instructor for clarification.
    Its the question which I came across while solving MCQ, its not the question given by my instructor

  5. #20
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    The question is about the number of elements you can store in that array.

    So, how many elements are in the first dimension (-1...m)?
    How many elements are in the second dimension (1...m)?

    If you know both numbers it shouldn't be hard to declare the array in valid C-Syntax.

    Bye, Andreas

  6. #21
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    Quote Originally Posted by shyjuu View Post
    According to that Post, suppose m=2

    A(-1..2 , 1..2 )

    I am still confused about the declaration , how to run this and know the output
    It's a psuedo code declaration. The first index of A goes from -1 to +2 and the second index of A goes from +1 to +2. So how many elements are there in A?

  7. #22
    Registered User
    Join Date
    Jul 2010
    Posts
    47
    Quote Originally Posted by rcgldr View Post
    It's a psuedo code declaration. The first index of A goes from -1 to +2 and the second index of A goes from +1 to +2. So how many elements are there in A?
    Thanks a lot you solved my query answer is m(m+2), you had given me the hint that I was looking for, thanks once again
    Solution if m=2 then -1,0,1,2 and 1,2 so we get Two dimensional array A[4][2], so there are 2(2+2)= 8 elements in array

    I think I am 100% right but if somebody thinks that I am WRONG somewhere then they can correct me

  8. #23
    Registered User
    Join Date
    Jul 2010
    Posts
    47
    Quote Originally Posted by AndiPersti View Post
    The question is about the number of elements you can store in that array.

    So, how many elements are in the first dimension (-1...m)?
    How many elements are in the second dimension (1...m)?

    If you know both numbers it shouldn't be hard to declare the array in valid C-Syntax.

    Bye, Andreas
    Thanks for the required hint

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in boolean and array
    By prathiksa in forum C Programming
    Replies: 7
    Last Post: 10-22-2012, 03:20 AM
  2. doubt while defining array and pointer
    By karthik537 in forum C Programming
    Replies: 4
    Last Post: 08-24-2010, 12:05 AM
  3. Array declaration doubt
    By finalsayan in forum C Programming
    Replies: 8
    Last Post: 03-29-2010, 09:56 AM
  4. a doubt about sending an array to a function
    By louis_mine in forum C Programming
    Replies: 13
    Last Post: 05-14-2005, 11:50 PM
  5. a Movement doubt in an array
    By louis_mine in forum C Programming
    Replies: 4
    Last Post: 02-03-2005, 09:12 PM