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 trial2 Answers
Stone Preston
42,016 Pointsprintf statements generally look like this:
printf("This is a variable with a value of %f that will be printed", someVariable);
the value of someVariable will be inserted into the string where the format specifier is (%f in this case). you use %f for floats, %d for ints, %c for chars, and there is a lot more as well.
you are almost correct. use double quotes around your string, and instead of using 14.5 use a format specifier. also your \n escape sequence is missing the n. you also forgot to close your string. fixing all that leads to this:
float radius = 14.5;
printf("A ball with a radius of %f inches.\n", radius);
since the variable you want to print is a float, you use %f as the format specifier
Mike Grady
197 Pointsfloat radius = 14.5; printf('A ball with a radius of 14.5 inches.\, radius);
Stone Preston
42,016 PointsStone Preston
42,016 Pointswhat have you tried so far?