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

Milan Amin
Milan Amin
194 Points

Create a float variable with the name 'radius' which has a value of 14.5

I am sure I am doing it write? Please advise, I thought the answer can be either of the following:

float 'radius'[0]; radius[0] = 14.5;

float radius[0] = {14.5};

3 Answers

The syntax you are using is for arrays. It looks like you're trying to create an array of size 0.

To create a float variable, you don't need the square brackets or the curly brackets, see below:

float radius = 14.5;
Milan Amin
Milan Amin
194 Points

Hi Kristen, thank you so much you are an angel!

The next part of the question says: Add a printf statement to print the radius variable. Here is what your output should look like: A ball with a radius of 14.5 inches.

So I put the answer as

printf("radius %f\n");

but then it says the output should look like, A ball with a radius of 14.5 inches

So then I thought the answer will be:

printf("radius %f\n", A ball with a radius of);

I am confused :(

Milan Amin
Milan Amin
194 Points

Ahh!! I don't it yaaaay!!!

I wrote out printf("A ball with a radius of %f\n, radius);

and it worked..!!

Thanks a lot Kristen, you are a huge help!!

Glad you got it figured out :)