Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

maytelabargamalaga
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;