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!

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


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 :)