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) Fundamentals of C Arrays

Curtis Curry
Curtis Curry
717 Points

Stumped and stuck, help!

float math_constants[0] = 2.71828; ^

I keep receiving one error each time I try to check my work. What exactly am I missing?

Hi Curtis,

What's the full code that you're using?

8 Answers

You're showing the instructions for task 1 but the code you're trying would indicate you're on task 2.

You want to make sure that you're adding to the existing code for each task you complete.

You would declare an array of type float with room for 2 floats like this: float math_constants[2];

Then the code you've been showing is for task 2 except you don't want to declare the float again since you already declared it in task 1.

So you should have 2 lines of code when trying to pass task 2.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Get rid of the ^. Does this make sense?

Edit: Delete the float.

Curtis Curry
Curtis Curry
717 Points

use of undeclared identifier 'math_constants' math_constants[0] = 2.71828; ^ 1 error generated.

That's what I am getting and can't seem to get around. Where am I going wrong?

Curtis Curry
Curtis Curry
717 Points

I removed the float but still get an error.

If you want to post all the code that you're trying to pass with then I can take a look.

Curtis Curry
Curtis Curry
717 Points

Declare an array of type float named math_constants. The array should be big enough to hold 2 numbers.

float math_constants[0] = 2.71828;

Curtis Curry
Curtis Curry
717 Points

That's the only line of code I have in there to try and complete that particular challenge.

Declare an array of type float named math_constants. The array should be big enough to hold 2 numbers.

Answer: float math_constants[2] = {2.3983, 1.022};

Assign the number 2.71828 to index 0 of math_constants.

Answer: math_constants[0] = 2.71828;