Keywords and Identifiers
- C language has 32 keywords, which are reserved by the compiler.
- They have a predefined meaning and cannot be used as variable names.
- C language is a case sensitive, all keywords must be written in lowercase.
The list of reserved keywords is given below.
Along with these basic keywords, C compiler vendors may provide their implementation specific keywords.
Basics usage of these keywords –
auto defines the storage type of an identifier.
break is used to terminate a loop.
case is used to define a resultant case. Out of N cases we may pick the desired case at run time.
char is the character data type.
const assigns constant properties to an identifier.
continue helps in jumping to the beginning of a loop and continue looping.
default specifies the default case in switch…case logic.
do used to define a do…while type of looping.
double is the 64 byte floating point type.
else is used in conditional if…else clauses to specify action for unsatisfied condition.
enum helps create enumerated constants.
extern is a storage type for accessing variables that are defined in different modules.
float is the 32 bit floating point type.
for helps define a loop with begin, increment and terminate condition for looping logic.
goto helps in jumping to any part of the program.
if helps to specify a condition clause.
int is the basic integer type.
long is a type specifier for basic data types.
register gives instruction to compiler to store the variable in CPU registers for faster access.
return helps return control from inside of a function to caller.
short type specifier for basic data types.
signed specifies, whether the variable may be assigned negative values and storage needs to consider the sign bit.
sizeof operator returns the size of any identifier.
static specifies the storage class of a variable.
struct provides a mechanism to group different variables into a single logical unit.
switch helps in choosing a case out of many cases.
typedef helps a programmer define his own data types.
union a mechanism to access the same storage in a different ways.
unsigned indicates that a variable will not hold negative values.
void represents the void type i.e. no type assigned.
volatile instructs the compiler that the variable should not be cached and always to be accessed from main memory.
while helps run a few statements repeatedly till the terminating condition is satisfied.
- Identifier is the name assigned by programmer to entities such as variables, functions, objects, structures, unions, etc.
- An identifier must be unique in its scope of use(we will discuss later about what is scope and storage type).
- Upper and lowercase letters are distinct in C, hence remember to use the variable name exactly as defined in your program.
How do you give a name to identifier ?
An identifier name may contain lower case alphabets(a to z), upper case alphabets (A to Z), numbers(0, 1,..,9) and underscore ‘_’ character.
int add(int value1, int value2)
result = value1 + value2;
Here value1, value2, result are identifiers created by programmer to store integers for computation. We have given the function identifier a name of “add”.
For better readability of your program, assign a name that matches to the purpose of the identifier.