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 trialPeter Escartin
893 PointsRadius Float variable?
In the first challenge it asks to create a float variable radius with the amount 14.5.
This is what I've submitted:
{ float radius = 14.5;
}
I'm pretty sure this is how you declare a float variable, but It's telling me to recheck my work. What am I doing wrong?
5 Answers
Jason Anello
Courses Plus Student 94,610 PointsYou don't actually need the curly braces when creating a variable.
Curly braces are used to denote a code block and you'll use them when you write functions, loops, conditionals, etc...
Jesse Richard
1,899 PointsI'm having problem with this course as well. I keep thinking it's missing a video.
Peter Escartin
893 PointsHmmm. So I tried it again and it submitted this time. Not sure what I could have done differently but for anyone else having this problem - make sure you're writing on the first line. This is what I submitted as my code -
float radius = 14.5;
Good luck!
Jason Anello
Courses Plus Student 94,610 PointsI'm confused now. Did you submit it the first time with the curly braces or without?
Peter Escartin
893 PointsJason Anello - Without the curly brackets the first time, hence my confusion as to why it wasn't running. I added the brackets in there for the post thinking that's what I was missing.
Jason Anello
Courses Plus Student 94,610 PointsThat's strange then because I don't see a difference between the two variable declarations.
I'm not sure if you're saying you put in the curly braces to post it as code but you need to use 3 backticks if you wanted to post it as code.