Cs112 - Programming Fundamental: Lecture # 06 - Tokens in C Syed Shahrooz Shamim
Cs112 - Programming Fundamental: Lecture # 06 - Tokens in C Syed Shahrooz Shamim
Lecture # 06 – Tokens in C
Syed Shahrooz Shamim
Junior Lecturer,
CS Department, UIT
Introduction To C Tokens
• In a passage of text, individual words and
punctuation marks are called tokens. Similarly, in C
programming the smallest individual units are
known as C tokens.
Special
Keywords Identifiers Constants Strings Operators
Symbols
Keywords
• Keywords serves as the building blocks for a
program statements. All keywords have a fixed
meaning and cannot be changed.
• Keywords cannot be used as normal identifier
names.
• Few Examples of keywords used in C are listed
below
– int
– break
– goto
– char
– switch
– void
Identifier
• Identifier refers to the name of variables, functions and arrays.
These are user defined names and consists of a sequence of
letters and digits.
• Both uppercase and lowercase letters can be used, and c
language is case sensitive. A special symbol underscore ( _ ) is
also permitted.
• Rules For Identifiers
– First character must be an alphabet.
– must consist of only letters, digits or underscore.
– Should not be a keyword and should not have any blank
space.
• Example:- int num;
char name;
Where num and name are identifier names.
Constants
• Constants refers to fixed values that do not change during the
execution of a program.
Constants
Numeric Character
Constants Constants
Single
Integer Real String
character
Constants Constants constants
constants
Strings
• Strings are nothing but array of characters ended
with null character (‘\0’). This null character
indicates the end of the string.
• Strings are always enclosed by double quotes.
Whereas, character is enclosed by single quotes in
C.
• Example :- char name[10];
In this example the variable name can store up
to 10 bytes.
Special Symbols
• The following special symbols are used in C having some
special meaning and thus, cannot be used for some other
purpose.
[] () {} , ; : * … = #