Each program elements in a C program are given a name called identifiers. Names given to identify Variables, functions and arrays are examples for identifiers. Keywords are pre-defined words in a C compiler.Each keyword is meant to perform a specific function in a C program
An identifier is nothing but a name assigned to an element in a program.
Example, name of a variable, function, etc. Identifiers are the user-defined names consisting of 'C' standard character set. As the name says, identifiers are used to identify a particular element in a program. Each identifier must have a unique name. These identifier are defined against a set of rules.
In C, we have 32 keywords, which have their predefined meaning and cannot be used as a variable name. These words are also known as “reserved words”. It is good practice to avoid using these keywords as variable name.
As C is a case sensitive language, all keywords must be written in lowercase. Here is a list of all keywords allowed in ANSI C.
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
continue | for | signed | void |
do | if | static | while |
default | goto | sizeof | volatile |
const | float | short | unsigned |
Keywords | Usage |
---|---|
if, else, switch, case, default | Used for decision control programming structure. |
int, float, char,short, double, long | These are the data types and used during variable declaration. |
for, while, do | types of loop structures in C. |
auto, signed, const,static, volatile,extern, register, unsigned | defines a variable. |
break | Used with any loop OR switch case. |
void | One of the return type |
goto | Used for redirecting the flow of execution |
return | This keyword is used for returning a value |
continue | It is generally used with for, while and do-while loops, when compiler encounters this statement it performs the next iteration of the loop, skipping rest of the statements of current iteration. |
enum | Set of constants |
sizeof | It is used to know the size. |
struct, typedef | Both of these keywords used in structures (Grouping of data types in a single record) |
union | It is a collection of variables, which shares the same memory location and memory storage |