Declarations

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

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, variables types do not have to be declared explicitly and are determined at run time 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.

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