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 trialshaun strickland
Courses Plus Student 93 PointsPrintf statement
I have the correct string but not the correct format, any advice?
4 Answers
Kevin Kenger
32,834 PointsHey Shaun,
What does your code look like?
shaun strickland
Courses Plus Student 93 PointsHello Kevin its printf("%f a ball with a radius of 14.5 inches")
Kevin Kenger
32,834 PointsOK you're close, and you've included %f
in the statement, which is great. But in order for the code to work properly, you need to swap out 14.5
for %f
. That way it takes the value of the float variable, and inserts it into your statement. Then, after your final quotation mark, you add a comma, then specify exactly which float variable to get.
Like this:
float radius = 14.5;
printf("A ball with a radius of %f inches.", radius);
shaun strickland
Courses Plus Student 93 PointsMy aha moment that made sense thanks kevin
Kevin Kenger
32,834 PointsAwesome, I love those! You're very welcome!