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 Objective-C Basics (Retired) Fundamentals of C Variables

Roger Green
Roger Green
643 Points

Not sure what I'm doing wrong.

The radius of a ball is 14.5

The float i wrote was: float radius = 14.5

The print statement I came up with is

printf("%f radius of a ball\n.")

3 Answers

Stone Preston
Stone Preston
42,016 Points

the challenge states: Here is what your output should look like: A ball with a radius of 14.5 inches.

currently your printf looks like this:

printf("%f radius of a ball\n.")

which will output 14.5 radius of a ball. which is incorrect.

you need your printf to output A ball with a radius of 14.5 inches. to do that you need to change your string a bit. see if you can figure it out

Stone Preston
Stone Preston
42,016 Points

your variable declaration is fine, you dont need to change that. it needs to be named radius. your printf needs to change.

remember that a printf statement generally looks like:

printf("some string with a format specifier %f in it", someVariable);

the value of someVariable will be inserted into the string whereever the format specifier is.

the output needs to be A ball with a radius of 14.5 inches. to do that it needs to look like this:

float radius = 14.5;

printf("A ball with a radius of %f inches.", radius);

that will output the correct string.

Roger Green
Roger Green
643 Points

Oh okay!! I get it now. Thank you.

Roger Green
Roger Green
643 Points

I changed it to this: float radius_of_a_ball = 14.5 in; printf("%f radius of a ball.\n" radius_of_a_ball);

But it keeps telling me this:

expected ')' printf("%f radius of a ball.\n" radius_of_a_ball); ^ note: to match this '(' printf("%f radius of a ball.\n" radius_of_a_ball); ^ 2 errors generated.