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 trialCurtis Curry
717 PointsStumped 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?
8 Answers
Jason Anello
Courses Plus Student 94,610 PointsYou'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
Treehouse Moderator 37,862 PointsGet rid of the ^. Does this make sense?
Edit: Delete the float.
Curtis Curry
717 Pointsuse 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
717 PointsI removed the float but still get an error.
Jason Anello
Courses Plus Student 94,610 PointsIf you want to post all the code that you're trying to pass with then I can take a look.
Curtis Curry
717 PointsDeclare 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
717 PointsThat's the only line of code I have in there to try and complete that particular challenge.
Jimesh Ullas
Courses Plus Student 66 PointsDeclare 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};
Jimesh Ullas
Courses Plus Student 66 PointsAssign the number 2.71828 to index 0 of math_constants.
Answer: math_constants[0] = 2.71828;
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Curtis,
What's the full code that you're using?