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

Variables

I need to create a float variable

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

3 Answers

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

thank you

float myfloatvalue =2.0; or float myfloatvalue; myfloatvalue=2.0;