We will discuss identifiers, variables and keywords in the ‘C’ programming language in this post.
Before we start programming, it is good to note that in most languages, we have to commonly declare the variables, functions, arrays we will work with.
This lets the compiler to allocate the appropriate amount of memory in the computer
Let us first see what are meant by variables in the ‘C’ programming language
What are variables?
Variables in ‘C’ are used to store values. We can store normal number values(‘integer’ in ‘C’ like 1, 2, 3…. or characters(char) like ‘C’ or decimals(float) like ‘4.75’.
Characters are defined as ‘char’ in ‘C’
Decimals are defined as ‘float’ and ‘double’ in ‘C’
Variable is a location in memory that is used to store a value.
An example of a variable is
int i=5;
Here, the variable ‘i’ is used to store an integer value of ‘5’.
Here are few rules of naming a variable in ‘C’:
- Variables should only begin with an underscore or an alphabet. They cannot begin with a number
- They should not have spaces between them
- Variable names should be unique to the program(as an example, there can only be one ‘i’ or ‘j’ as a variable name)
- It is better to declare the variable names since they will initially have junk values in them initially

What are keywords?
Keywords are reserved words that cannot be used as variable names. These keywords have special meaning to the ‘C’ compiler and hence they should not be used as variable names
Some examples of keywords are:
int, float, char, double, if, else,struct, while, do, signed, void etc
If you do try to create a variable name with a ‘keyword’, the compiler will complain and throw an error
What are identifiers?
Identifiers are identified by their names. We use identifiers for naming variables, arrays, functions and other user-defined functions.
The rules for naming identifiers are similar to naming variables
- they should begin with an alphabet or an underscore
- they should not begin with a ‘space’
- they can contain alphabets, numbers
- they cannot contain a space
- they cannot contain a reserved keyword
Examples of identifiers are:
int deep = 2; ———> This is a variable
int hello[]={5, 10, 15}; ——> This is an array
Here, ‘deep’ and ‘hello[]’ are identifiers that are used to name the variable and array.
Let us see a simple program that makes use of identifiers and variables:
// Online C compiler to run C program online
#include <stdio.h>
int main() {
// Write C code here
int i=10;
int hello[]={5,10, 15, 20};
printf("The value of i is %d", i);
return 0;
}
The output of the above program will be as follows:
The value of i is 10
=== Code Execution Successful ===
Few points of the ‘C’ programming language:
- All the statements have to end with a semi-colon
- The ‘C’ programming language is case-sensitive
- Comments statements give information about specific lines of code for anybody who might read the program. These ‘comment’ statements begin with a “//” in ‘C’
We have seen keywords, variables and identifiers in the ‘C’ programming language in this post.
Let us see a simple program in the next ‘C’ post.
This post is for the BlogchatterHalfMarathon challenge by Blogchatter