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

I did this problem earlier and it worked fine can someone check this.

I'm trying to revise my notes and now I can't get this to work. Can someone tell me what the problem is. Ty

arrays.c
float math_constants [2];
float math_constants[2] = {2.71828};

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,867 Points

Assign the number 2.71828 to index 0 of math_constants.

Hi, Hans, 3 problems here with the code.

  1. no need to re-declare float type in line two; line 1 has done so already.
  2. The challenge is asking for index of 0, not index of 2
  3. don't surround the 2.71828 with {}.

The corrected version looks like this.

float math_constants [2];
math_constants[0] = 2.71828;

William Li I was thinking that, so tried that variation before also and again just now, and it didn;t work. I almost think there is something wrong with this problem. I solved it earlier and it looks easy enough to solve, but it keeps saying I'm wrong. Check out what I have to see if there is something I'm not seeing. Imgur

William Li Oh I see it now that its next to yours, I wrote float, and wasn't supposed to. I must be tired I'm making simple mistakes and not realizing it. Ok.

William Li Oh I see it now that its next to yours, I wrote float, and wasn't supposed to. I must be tired I'm making simple mistakes and not realizing it. Ok.

William Li Oh I see it now that its next to yours, I wrote float, and wasn't supposed to. I must be tired I'm making simple mistakes and not realizing it. Ok.