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 Variables

float variable

my code:

{

float radius = 14.5;

printf("%f\n", radius);

return 0;

}

xcode accepts, tree house does not. where's the error?

4 Answers

Micahyah Hawkins
Micahyah Hawkins
3,496 Points

What is the question in the course exactly. I just did the two questions in the related content of Objective-C Basics. The questions are very specific in what you need to do.

The first question was Create a float variable named 'radius' with the value '14.5'. (Do not write the main function).

So to create this float variable you would type.

float radius = 14.5;

The second question in the task was: 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 we keep the previous declaration then add the printf function. Remember the question is asking you to create a sentence of "A ball with a radius of 14.5 inches."

float radius = 14.5; printf("A ball with the radius of %f inches.", radius);

In your code above you are putting a new line command at the end of the variable and not creating the sentence that it is asking for. Your code will work in Xcode because technically the code is correct but it's not what the question is asking you to do.

Also you added the return 0; at the end when the question from the beginning stated do not create the function. You are only to create the code it asks.

I hope this helps.

Hi Adam,

You don't need the curly braces or the return statement. Only the variable initialization and the printf.

This code challenge is looking for a very specific output: A ball with a radius of 14.5 inches.

Your current output would be 14.5

Try updating your format string so that it matches the output the challenge is expecting.

Perfect, thank you!

Thank you for your help!