Basically, Tokens in C Language are one of the most significant elements. In fact, you need one or more tokens in any application or even the simplest program makes use of tokens.

Understanding Tokens in C Language

In fact, the smallest unit that we use in a program is referred to as a token. Since, in a program, we use identifiers, variables, keywords, and so on. Hence, all these are known as tokens.

As a matter of fact, the C language has six categories of tokens – keywords, identifiers, operators, constants, strings, and special characters. While the keywords are known to compilers for carrying out a specific pre-defined function. Also, they are called reserved words meaning we can not name a variable with the same name as a keyword. For instance, some examples of keywords in C are for, while, do, break, if, switch, struct, and so on.

Similarly, we have identifiers to name variables, structures, arrays, and user-defined functions. The identifiers need to be unique in a given scope. Further, a constant refers to a specific value. For example, the string “hello” is a constant that we can assign to a variable. Also, we can’t change the value of a constant.

Likewise, an operator is a symbol that carries out a specific well-defined task such as the addition of two numbers or a comparison. In C, we have different categories of operators like arithmetic operators, relational operators, etc.

In C. strings terminate with a null character or ‘\0’. Basically, in C, we form a string as an array of characters. Lastly, we have many special characters in C. For instance, [ ] is used to represent the array subscript. Likewise, we use () in a function call or function definition.


Further Reading

50+ C Programming Interview Questions and Answers

C Program to Find Factorial of a Number