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 trialBen Gooden
241 PointsChange radius to 1 decimal place
When running my radius code on Xcode, how do I get it to 1 decimal place? "A ball with the radius of 14.500000 inches." This is what my code looks like, and it will not let me pass (presumably) because of the amount of "0's" after the 14.5
3 Answers
eirikvaa
18,015 PointsIt could be your string formatter. Check that you're using %for float variables.
Ben Gooden
241 PointsThis is the code that I am using...
float radius = 14.5;
printf("a ball with the radius of %f.\n", radius);
eirikvaa
18,015 PointsVery strange, although I passed with this code:
float radius = 14.5;
printf("A ball with a radius of %f inches", radius);
It's almost the exact same thing, but try it. Maybe refresh your page, because it might be a bug.
RASHU BHATNAGAR
Courses Plus Student 2,669 Pointsprintf("a ball with the radius of %f.\n", radius); you should have written inches instead of \n. The editor expects you to write the code exactly in the manner the question has been provided.