Declarations

Learn the C syntax required for declaring variables of different types.

Declaring a variable in C

Declaring a variable means to specify the name of the variable (and possibly its data type) so that the programming environment can reserve space in memory for that variable. Once a variable is declared, values that are assigned to it are held in the memory location reserved for it.

Unlike in languages like Python, R, Octave/MATLAB, etc., which are dynamically typed languagesIn a dynamically typed language, variable types do not have to be declared explicitly and are determined at runtime depending on the type of value stored in it., the C language is a statically typed languageIn a statically typed language, variable types have to be declared explicitly and are known at compile time.. From a practical point of view, this means that in C we have to declare, up front, the type of every variable we use.

In languages like Python, we can do crazy stuff like this:

Create a free account to access the full course.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy