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

help

hekp

1 Answer

Stone Preston
Stone Preston
42,016 Points

task 1 states: Declare an array of type float named math_constants. The array should be big enough to hold 2 numbers.

declaring an array generally looks like this:

dataType arrayName[size];

so I could create an an array that holds 4 float numbers like this:

float myArray[4];

task 2 states: Assign the number 2.71828 to index 0 of math_constants.

you can assign values to indexes of an array like so:

myArray[3] = 2.1;

which would assign 2.1 to the 3rd index (4th item since indexes start at 0)

task 3 is similar to the second.

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

you can print the value of an aray using an index just like oyou did when you assign it

printf("some number from my array: %f", myArray[0]);

would print the first value in myArray out where the format specifier is