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 trialRobin Hebert
71 PointsI cant get past this.
I put in the right code for float but it wont take it.
11 Answers
Stone Preston
42,016 Pointsremember, creating a float variable looks something like
float myFloat = 1.0;
make sure you didnt make the mistake of using '14.5' for the floats value. A float is a number, it is not enclosed in quotes
Robin Hebert
71 Pointsfloat radius = 14.5; printf("%f radius of ball\n", radius);
Stone Preston
42,016 PointsThe challenge states: "Add a printf statement to print the radius variable. Here is what your output should look like: A ball with a radius of 14.5 inches."
you put:
printf("%f radius of ball\n", radius);
which would output 14.5 radius of ball
the challenge needs the output to be A ball with a radius of 14.5 inches
So your printf's output is incorrect.
remember that the variables value shows up in the string where you put the format specifier. See if you can figure it out now
Robin Hebert
71 PointsOK I will retry it.
Robin Hebert
71 PointsI cant get it....
Robin Hebert
71 Pointsfloat radius = 14.5; printf("%f ball with a radius of\n", radius);
Robin Hebert
71 Pointsstill didnt work
Stone Preston
42,016 Pointsyouve tried
printf("%f ball with a radius of\n", radius);
remember what I said about the value of the variable being inserted into the string where the format specifier is?
with that printf statement, the value of radius is inserted at the front of the string where your %f is. which would outpu
14.5 ball with a radius of
which is still incorrect. The format specifier is in the wrong place. that %f needs to be where you want 14.5 to show up.
Robin Hebert
71 Pointsoh ok, I thought it always had to be in the beginning.
Stone Preston
42,016 Pointsyeah it can go anywhere in the string, as long as its in between the " ".
Robin Hebert
71 Pointsok that makes all the difference... thanks...back to the drawing board. this newbie will laugh at this someday.
Robin Hebert
71 Pointsya got it!
Stone Preston
42,016 PointsStone Preston
42,016 Pointsplease post the code you tried to use