Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Pointers and Memory Array Size and Length

Challenge Task: Pointers and Memory

Declare a float array named real_numbers that will hold 5 float numbers.

one of the answers is: float real_numbers[5];

could it also be?: float real_numbers[4];

3 Answers

Hi Mark,

If the array needs to contain 5 elements , then it needs to be defines as: float real_numbers[5]; where as the indexes will be starting from 0 to 4 , so altogether it will be containing 5 elements, with the first element starting from index 0 (real_number[0]) and last element will be of index 4 (real_number[4])

I hope it clarifies your confusion a little more...

Scott Evans
Scott Evans
4,236 Points

To be blunt, no. If you want 5 element within the array you would have to specify 5.

I can see where your confusion is coming from though, the fact that array indexes start at 0. Just a slight misconception.

Thanks, Scott