Friday, July 29, 2016

C Basics - Tokens in C

Tokens are basic building blocks of C Programming. The smallest individual unit in a c program is known as a token. In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements.

For example, the following C statement consists of five tokens −

printf("Hello, World! \n");
The individual tokens are −

"Hello, World! \n"

Tokens are keyword, identifier, constant, variable or any symbol which has some meaning in C language. A C program can also be called as collection of various tokens. Token in C includes characters, keywords, constants, identifiers, strings, special symbol, operators, and comments.

Characters – A character denotes any alphabet, digit or symbol used to represent information.

Keywords – Keywords are the words whose meaning has already been explained to the C compiler.

Constants – Constants are expressions with a fixed value

Identifiers – The term identifier is usually used for variable names

Strings – Sequence of characters.

Special Symbols – Symbols other than the Alphabets and Digits and white-spaces.

Operators – A symbol that represent a specific mathematical or non-mathematical action.

Semicolon - In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

Comments - Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −

/* my first program in C */

You cannot have comments within comments and they do not occur within a string or character literals.

Related topics:
Character Set in C   |   White Space Characters in C   |   Trigraph Characters in C   |   Extended Characters in C   |   Escape Sequence in C   |   Comments in C   |   Keywords in C   |   Identifiers in C   |   Declaration in C

List of topics: C Programming

No comments:

Post a Comment