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

iOS Objective-C Basics (Retired) Fundamentals of C Variables

create radius float 14.5

I created a float like float radius = 14.5 and it still says its wrong.

7 Answers

Stone Preston
Stone Preston
42,016 Points

did you include a semicolon at the end of your statement?

Yes

Stone Preston
Stone Preston
42,016 Points

your code should look like this

float radius = 14.5;

I just tried that in the challenge and it worked.

here was my code

include <stdio.h>

int main() { float radius = 14.5;

   printf("radius is %f.\n", radius);
                  return 0;

}

okay got it to work thank you

Stone Preston
Stone Preston
42,016 Points

the 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.

I 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
Stone Preston
42,016 Points

the 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);