C Programming Identifiers and Keywords

C Programming Identifiers and Keywords

In this tutorial, you will learn about keywords and identifier in C programming that are part of the syntax. Also, you will learn about identifiers and a proper way to name a variable. Keywords and identifier in C programming plays an important role in Coding in c.

C Identifiers

In C language identifiers are the names given to variables, constants, functions and user-defined data. These identifiers are defined against a set of rules.
Example
int marks;
char studentName[30];
Here, marks and studentName are identifiers.
 

Rules for writing an identifier

  1. An Identifier can only have alphanumeric characters( a-z , A-Z , 0-9 ) and underscore( _ ).
  2. The first character of an identifier can only contain alphabet( a-z, A-Z ) or underscore ( _ ).
  3. Identifiers are also case sensitive in C. For example, name and Name are two different identifiers in C.
  4. Keywords are not allowed to be used as Identifiers.
  5. No special characters, such as semicolon, period, whitespaces, slash or comma are permitted to be used in or as Identifier.

C Keywords

Keywords are specific reserved, predefined words in C each of which has a specific feature associated with it. Almost all of the words which help us use the functionality of the C language are included in the list of keywords. So you can imagine that the list of keywords is not going to be a small one!

Properties of Keywords

  1. All the keywords in C programming language are defined as lowercase letters so they must be used only in lowercase letters.
  2. Every keyword has a specific meaning, users can not change that meaning.
  3. Keywords cannot be used as user-defined names like variables, functions, arrays, pointers etc..
  4. Every keyword in C programming language represents something or specifies some kind of action to be performed by the compiler.

There are a total of 32 keywords in C:
C-keywords

Basics usage of these keywords

if, else, switch, case, default – Used for decision control programming structure.
break – Used with any loop OR switch case.
int, float, char, double, long – These are the data types and used during variable declaration.
for, while, do – types of loop structures in C.
void – One of the return type.
goto – Used for redirecting the flow of execution.
auto, signed, const, extern, register, unsigned – defines a variable.
return – This keyword is used for returning a value.
continue – It is generally used with for, while and do-while loops, when the compiler encounters this statement it performs the next iteration of the loop, skipping rest of the statements of the current iteration.
enum – Set of constants.
size of – 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
 
 
In this tutorial, you will learn about keywords and identifier in C programming that are part of the syntax. Also, you will learn about identifiers and a proper way to name a variable.
 
 
 

Be the first to comment

Leave a Reply

Your email address will not be published.


*