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

Radius of 14.5

What am I doing incorrectly with my printf?

float radius = 14.5;

printf("%f a ball with a radius of 14.5", radius);

5 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

your printf is not making much sense. It's saying:

"14.5 a ball with a radius of 14.5"

Syntax wise, your printf is correct though

Thanks for the help Thomas....

Since float radius = 14.5; has the out come of 14.5 a ball with radius of 14.5. What would be the best way the start my variable? Would it just be float radius;?

Thomas Nilsen
Thomas Nilsen
14,957 Points

Try something like this instead:

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

What's the reasoning for putting %f after the "of" and why can't we put it in front of the "A ball"?

Thomas Nilsen
Thomas Nilsen
14,957 Points

you can put %f wherever you like, but in the particular challenge you're referring to, they want you to write it like that.