Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 19, 2021 09:19 am GMT

Tokens in the C language

The individual elements of a program are called Tokens. In a C program, a number of individual units or elements occur. These elements are called C Tokens. In the C language, the following 6 types of tokens are available:

Identifiers
Keywords
Constants
Operators
Special Characters
Strings
Identifiers:
Each program element in a C program is called an identifier. An identifier is a variable that holds a value and stores it in the memory.

Rules for declaring identifiers:
The identifier should consist of alphabets from a to z and A to Z.
It may contain numerical values from 0 to 9.
It may contain the underscore value.
The starting character of an identifier must always be a letter. Example: Variables, functions, labels, etc.
Keywords
Keywords are words whose meaning has already been defined by the computer they are pre-defined words in the C compiler. Each Keyword is meant to perform a specific function in a C program. Keywords are case sensitive and are written in lower case. The C language has 32 keywords, they are:

Constants
A constant is a fixed value that cannot be altered during the execution of a program. C Constants can be classified into two categories:

Primary Constants
Secondary Constants
Primary constant
A primary constant is, again, divided into these three types:

Numeric
Character
Logical
Numeric is subdivided into two types, Integer and Float.
Character is subdivided into two types, Single Character and String
Secondary
The secondary constant is divided into the following types:

Arrays
Structures
Union
Pointer
Enum etc.
Operators:
Operators are symbols that provide instructions for the performance of various mathematical and logical operations. Operators are tools that can alter data and variable values.

Operators are classified into the following eight types:

Arithmetic Operators
Relational Operators
Logical Operators
Increment/Decrement Operators
Assignment Operator
Bitwise Operators
Conditional Operators
Special Operators

Special characters
All the characters other than a to z, A to Z, and 0 to 9 are special characters. Example: {,},[,],(,)

A character data type consumes 8-bits of memory, which means that one can store anything in a character whose ASCII value lies between -127 and 127. Thus, it can hold any of the 256 different possible values.

String
A string is a group of characters that should be enclosed in double quotations.

For example: char string[]=gitam;

Variable
A variable is a user-defined word that, depending on the data type, will have some storage area. The variables value will be changed during the program execution, and the data type and its value will be changed during the program execution. The declaration of a variable is:

Rules for variables
A variable is a combination of letters and digits.
The length of the variable is no more than 31 characters; however, the length is normally more than 8 characters.
A variable should not be a reserved word.
"Special symbols, except the underscore(_),are not allowed.
The first character in a variable must be an alphabet.
No commas or blank spaces are allowed within a variable.


Original Link: https://dev.to/221910301048/tokens-in-the-c-language-3ih9

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To