Here is how you can create or declare a new variable in the C language,
data_type var_name;
Copy
where, data_type is a valid data type (along with datatype modifiers, if required) and var_name is the name of the variable.
For example,
int marks;
Copy
Here, marks
is the name of the variable, and it can store values of int
type.
Once we have declared or created the variable, then we can assign a value to it. This is called variable definition.
// variable declaration
int marks;
// variable definition
marks = 10;
Copy
We can do declaration and definition in a single step too, like this (recommended).
int marks = 10;