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 trialChris Taylor
3,446 Pointscreate radius float 14.5
I created a float like float radius = 14.5 and it still says its wrong.
7 Answers
Stone Preston
42,016 Pointsdid you include a semicolon at the end of your statement?
Chris Taylor
3,446 PointsYes
Stone Preston
42,016 Pointsyour code should look like this
float radius = 14.5;
I just tried that in the challenge and it worked.
Chris Taylor
3,446 Pointshere was my code
include <stdio.h>
int main() { float radius = 14.5;
printf("radius is %f.\n", radius);
return 0;
}
Chris Taylor
3,446 Pointsokay got it to work thank you
Stone Preston
42,016 Pointsthe second part of the challenge states that your output should read "A ball with a radius of 14.5 inches"
your output would read "radius is 14.5." you need to make sure your output string matches what the code challenge asks for. Your use of printf is correct, however the string you pass to it is not.
Kathy Gleason
Courses Plus Student 596 PointsI apologize if it's bad form to add a question onto an existing thread but I'm stuck on the same challenge, but the second part. I'm very new so this is probably a dumb question but can anyone tell me what I'm doing wrong on this code?
printf("%f A ball with a radius of 14.5 inches\n.", radius);
It's supposed to say a ball with a radius of 14.5 inches...
Stone Preston
42,016 Pointsthe variable will show up in the string where the format specifier is. in your case the variable radius has the value 14.5 so your output would be
"14.5 A ball with a radius of 14.5 inches"
what you need to have is
printf("A ball with a radius of %f inches", radius);