-
November 9th, 2011, 07:02 PM
#1
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.
-
November 9th, 2011, 07:26 PM
#2
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++?
-
November 9th, 2011, 07:54 PM
#3
Re: Having trouble getting started
Stuck on trying to declare C++ arrays
-
November 9th, 2011, 08:16 PM
#4
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.
-
November 9th, 2011, 08:17 PM
#5
Re: Having trouble getting started
I believe this is the answer
int aRay[] = {9, 7, 5, 3, 1};
-
November 9th, 2011, 09:21 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|