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

Print the value of the first item in the math_constants array. Your output should look like this: Euler's number = 2.718

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

printf("PI %f\n", math_constants[0]);

5 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Your not printing what is asked:

"Euler's number = 2.718" is the string. Which means it would look something like this:

printf("Euler's number = %f", math_constants[0]);
Holger Liesegang
Holger Liesegang
50,595 Points

Hi Matt,

Challenge task 4 of 4 "Print the value of the first item in the math_constants array. Your output should look like this: Euler's number = 2.71828" should look like

float math_constants[2];
math_constants[0] = 2.71828;
math_constants[1] = 1.41421;
printf("Euler's number = %f", math_constants[0]);

You were asked to print out "Euler's number = " in task 4 of 4 but you used "PI" and a new line "\n" by mistake.

Your printf statement is setup correctly and you're passing in the correct second argument.

The problem is that your format string does not match up with the output they want.

Your printf will produce "PI 2.71828"

they want the output to be "Euler's number = 2.71828"

See if you can change your format string to match that output.

Holger Liesegang
Holger Liesegang
50,595 Points

Thomas Nilsen Jason Anello - maybe some kind of "attention - an answer is already in progress" warning should be implemented in the forum to avoid the situation of 3 simultaneous answers :-)

...well, at least nobody could blame that he doesn't get an answer here :-)

Thomas Nilsen
Thomas Nilsen
14,957 Points

That would be pretty helpful actually! :)

Yes, I didn't refresh before posting. A notification would be helpful. I think this happens a lot.

After I saw the other two answers, I thought "this one is pretty well covered".

thanks people this helps