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 trial

brycecampbell
2,112 Pointsvariables: first challenge part 2
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.
3 Answers

brycecampbell
2,112 Pointsi know that printf substitutes %f (or other %?) with the variable that follows the string after the comma.but every time I get to the first challenge part 2 where it says "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" . It is saying i have the correct string, but not the correct format...whenever i input this (printf("%f A ball with a radius of 14.5 inches.\n", radius); what is the correct format please and thank you... srry but i have a hard time understanding

Stone Preston
42,016 Points"Im adding the printf() statement in task 2 for this challenge and Im not sure why this is not passing: float radius = 14.5; when input printf("%f A ball with a radius of 14.5 inches.\n", radius);"
because the variable is placed into the string where the format specifier is. The output of
printf("%f A ball with a radius of 14.5 inches.\n", radius);
is
14.5 A ball with a radius of 14.5 inches

brycecampbell
2,112 Pointsthank you i appreciated the help

Stone Preston
42,016 PointsI answered this question for you earlier here. Did you look at that at all?

brycecampbell
2,112 Pointsevery time trying to input prinf("%f", radius); it say a syntax error

Stone Preston
42,016 Pointsthe questions says the output should be
A ball with a radius of 14.5 inches
printf("%f", radius);
does not output that result. You need the words A ball with a radius of before the specifier and inches after

brycecampbell
2,112 PointsIm adding the printf() statement in task 2 for this challenge and Im not sure why this is not passing: float radius = 14.5; when input printf("%f A ball with a radius of 14.5 inches.\n", radius);

Stone Preston
42,016 Pointsno problem
Stone Preston
42,016 PointsStone Preston
42,016 Pointssee above. your code
printf("%f A ball with a radius of 14.5 inches.\n", radius);
outputs
14.5 A ball with a radius of 14.5 inches.
which is not right. you need
printf("A ball with a radius of %f inches.\n", radius);
which outputs
A ball with a radius of 14.5 inches.
see how the value of the variable gets placed into the string where the format specifier is?