Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

C Programming Tokens Building Blocks of Code

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

C Programming Tokens Building Blocks of Code

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

C Programming Tokens:

Building Blocks of Code


Welcome! Let's explore the foundational elements of C programming:
tokens. These tiny units carry meaning and structure the language.
Understanding Tokens
Definition Compiler's Role

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.

5 Punctuation 6 Preprocessor Directives


Separators that structure the program and make it Special tokens beginning with '#' that provide
easier to parse. instructions to the preprocessor before compilation.
Keywords: The
Language's Foundation
Examples Purpose
int, float, while, return, if, Keywords control program
else, for, void, break, flow, define data types, and
continue, switch, etc. specify operations. They
cannot be used as identifiers.
Identifiers: Naming Program Elements

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!

You might also like