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

arrays.c

having trouble understanding "Declare an array of type float named math_constants. The array should be big enough to hold 2 numbers". ... c int main() {

float numbers_geeks_love [] = {3.1415,1.6180,1.4142};


printf("PI %f\n", numbers_geeks_love [0]);
printf("golden ration %f\n", numbers_geeks_love [1]);
printf("square root of %f\n", numbers_geeks_love [2]);

int primes [] = {2, 3, 5, 7};
printf("the first 4 prime numbers %d %d %d %d\n", primes [0], primes[1], primes[2], primes[3]);

float math_constants [2];

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


return 0;

} ... I hope this is the correct way to do this, very new at this (today in fact). Thanks

2 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Ronnie,

Challenge #Arrays# 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" :

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

...the printed text has to be "Euler's number = ..." and I honestly don't know where you got the rest of this code like "float numbers_geeks_love..."

Thank you, I was attempting to answer a lesson task. My apologies for any confusion.

Thank you, I was attempting to answer a lesson task. My apologies for any confusion.