CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2011
    Posts
    3

    Having trouble getting started

    If someone can help me out with this homework question that would be great!

    Data Type Array Name Array Data
    --------- ---------- -------------
    integer aRay 9 7 5 3 1

    Code the declaration and initialization of the one-dimensional array named aRay in one statement.


    I just need a push in the right direction.

  2. #2
    Join Date
    Aug 2009
    Posts
    440

    Re: Having trouble getting started

    Are you trying to read a file in that has the above format? Or, are you stuck on how to declare arrays in C++?

  3. #3
    Join Date
    Nov 2011
    Posts
    3

    Re: Having trouble getting started

    Stuck on trying to declare C++ arrays

  4. #4
    Join Date
    Aug 2009
    Posts
    440

    Re: Having trouble getting started

    I'd go over: http://www.cplusplus.com/doc/tutorial/arrays/

    And, read the whole thing too, it will do you more good in the long run rather than searching the page for the answer to your question.

  5. #5
    Join Date
    Nov 2011
    Posts
    3

    Re: Having trouble getting started

    I believe this is the answer

    int aRay[] = {9, 7, 5, 3, 1};

  6. #6
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Having trouble getting started

    Looks okay to me. Normally, you'd specify the array size as well (5 or greater is required in this case), but you can omit it when you specify an initializer list, since the size can be deduced automatically.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured