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) 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,868 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.