Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Problem declaring arrays

I have a question in regards to the problem being asked. It's asking to declare a float named real_numbers with an array of 5. I've typed up float real_numbers [] = {1,2,3,4,5} and got an error saying remember when saying how many there are you must state it in real_numbers[5]. Is it telling me to go the long way around? such as: float real_numbers[5] real_numbers[0] = 1.1 etc?

Thank you for all your help and explanation to my question.

float real_numbers [] = {1,2,3,4,5}
Greg Kaleka
Greg Kaleka
39,019 Points

Hi Steven,

William's answer looks right to me.

Aside from this, however, you should really be taking this newer version of the Objective-C Basics course, rather than the one you're taking now.

Happy coding!

1 Answer

William Li
William Li
Courses Plus Student 26,867 Points

problem here is that the on step 1, the challenge only asks you to declare a 5-items float Array variable, but not assigning any values to it just yet.

float real_numbers [5];

This would be suffice. hope it helps.