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 trialRoger Green
643 PointsNot sure what I'm doing wrong.
The radius of a ball is 14.5
The float i wrote was: float radius = 14.5
The print statement I came up with is
printf("%f radius of a ball\n.")
3 Answers
Stone Preston
42,016 Pointsthe challenge states: Here is what your output should look like: A ball with a radius of 14.5 inches.
currently your printf looks like this:
printf("%f radius of a ball\n.")
which will output 14.5 radius of a ball
. which is incorrect.
you need your printf to output A ball with a radius of 14.5 inches
. to do that you need to change your string a bit. see if you can figure it out
Stone Preston
42,016 Pointsyour variable declaration is fine, you dont need to change that. it needs to be named radius. your printf needs to change.
remember that a printf statement generally looks like:
printf("some string with a format specifier %f in it", someVariable);
the value of someVariable will be inserted into the string whereever the format specifier is.
the output needs to be A ball with a radius of 14.5 inches.
to do that it needs to look like this:
float radius = 14.5;
printf("A ball with a radius of %f inches.", radius);
that will output the correct string.
Roger Green
643 PointsOh okay!! I get it now. Thank you.
Roger Green
643 PointsI changed it to this: float radius_of_a_ball = 14.5 in; printf("%f radius of a ball.\n" radius_of_a_ball);
But it keeps telling me this:
expected ')' printf("%f radius of a ball.\n" radius_of_a_ball); ^ note: to match this '(' printf("%f radius of a ball.\n" radius_of_a_ball); ^ 2 errors generated.