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 trialmaytelabargamalaga
Courses Plus Student 6,465 PointsVariables
I need to create a float variable
3 Answers
Kristian Terziev
28,449 PointsThe way you declare a variable in C is <type><name> = value. You can omit the value and add it later. So to declare this variable you should write float followed by the name of the variable. For example: float a;
maytelabargamalaga
Courses Plus Student 6,465 Pointsthank you
Meek D
3,457 Pointsfloat myfloatvalue =2.0; or float myfloatvalue; myfloatvalue=2.0;
Kevin Lozandier
Courses Plus Student 53,747 PointsKevin Lozandier
Courses Plus Student 53,747 PointsSince float is an existing type of value in C, you should be able to create a new float variable merely using
float
to prefix the variable name and the value you want:float my_float_value = 2.0;