Codecademy Logo

Variables

C Variable Names

In C variable names must follow specific rules:

  • Names can only be composed of upper and lower case letters, numbers, and underscores.
  • The first character must be a letter (upper or lower case).
  • No keywords are allowed as the full name (int is not allowed but int_count would work).

Data Types in C

The main data types in C are: int, float, double, and char.

Setting Variables in C

Variables in C can be initialized with values at their declaration or have their values set later in the code.

Variable Casting in C

In C a variable can be cast explicitly or implicitly from one data type to another. They can then be used directly or stored in another variable.

Learn more on Codecademy