C Programming Tokens Building Blocks of Code
C Programming Tokens Building Blocks of Code
Tokens are the smallest meaningful units in a C program, The C compiler breaks down source code into tokens for
forming the basis of the language's syntax. analysis and code generation.
Types of Tokens
1 Keywords 2 Identifiers
Reserved words with predefined meanings, Names given to variables, functions, arrays, and
controlling program flow, data types, and other program elements.
operations.
3 Constants 4 Operators
Fixed values that don't change during program Symbols used to perform operations on variables
execution, including integers, floats, characters, and and values. They come in various categories.
strings.
Rules Examples
Identifiers must begin with a letter or underscore, followed x, main, sum, totalAmount, myFunction.
by letters, digits, or underscores. They are case-sensitive.
Operators: Performing Actions
Arithmetic 1
+, -, \*, /, % for mathematical calculations.
2 Relational
==, !=, <, >, <=, >= for comparing values.
Logical 3
&& (AND), || (OR), ! (NOT) for combining logical expressions.
4 Assignment
=, +=, -=, \*=, /=, %= for assigning values to variables.
Increment/Decrement 5
++, -- for increasing or decreasing variable values.
6 Bitwise
&, |, ^, ~, <<, >> for operating on individual bits.
Conditional (Ternary) 7
? : for selecting one of two expressions based on a condition.
8 Comma
, for separating multiple expressions.
Tokens in Action
By understanding and using tokens effectively, you can build complex and functional C programs. Keep exploring and
experimenting with different tokens!