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 trialBrian Pemberton
4,902 PointsWhy is this the wrong format?
Not sure what I am doing wrong here.
float radius;
radius = 14.5;
printf("A ball with a radius of %.2f inches.",radius);
2 Answers
Nick Janes
5,487 PointsYou said %.2f in your string. It should just be %f.
Ellen Tunik
1,028 PointsYou are doing OK in general. %.2f means - two numbers after floating point - 14.50. %.3f - three numbers after floating point - 14.500. and so on %.1 - 14.5.
But I'm not sure what exactly the task is about and why you get some errors.
Nick Janes
5,487 PointsFor the challenge, they just want %f. This is what they're looking for.
float radius;
radius = 14.5;
printf("A ball with a radius of %f inches", radius);
Brian Pemberton
4,902 PointsThank you for your help I guess what is confusing is
float radius = 14.5;
printf("A ball with a radius of %f inches", radius);
outputs to
A ball with a radius of 14.500000255 inches