0% found this document useful (0 votes)
51 views9 pages

Cs112 - Programming Fundamental: Lecture # 06 - Tokens in C Syed Shahrooz Shamim

This document discusses the different types of tokens in the C programming language. There are six main types of tokens: keywords, identifiers, constants, strings, special symbols, and operators. Keywords are reserved words that serve as building blocks for program statements. Identifiers are user-defined names for variables, functions, and arrays. Constants refer to fixed values that do not change during program execution. Strings are arrays of characters ended by a null character. Special symbols have predefined meanings, like brackets and parentheses. Operators are used to perform logical and mathematical operations.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views9 pages

Cs112 - Programming Fundamental: Lecture # 06 - Tokens in C Syed Shahrooz Shamim

This document discusses the different types of tokens in the C programming language. There are six main types of tokens: keywords, identifiers, constants, strings, special symbols, and operators. Keywords are reserved words that serve as building blocks for program statements. Identifiers are user-defined names for variables, functions, and arrays. Constants refer to fixed values that do not change during program execution. Strings are arrays of characters ended by a null character. Special symbols have predefined meanings, like brackets and parentheses. Operators are used to perform logical and mathematical operations.

Uploaded by

Ghazan Aqeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

CS112 - PROGRAMMING FUNDAMENTAL

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.

• C language has six types of tokens, and programs


are written using these tokens and the syntax of the
language.
Types Of 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.

• Basic types of C constants are shown in the flowchart

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.
[] () {} , ; : * … = #

• Braces{}: These opening and ending curly braces marks the


start and end of a block of code containing more than one
executable statement.

• Parentheses(): These special symbols are used to indicate


function calls and function parameters.

• Brackets[]: Opening and closing brackets are used as array


element reference. These indicate single and multidimensional
subscripts.
Operators
• The symbols which are used to perform logical and
mathematical operations in a C program are called
C operators.

• Operators used in C program are


• Arithmetic operators
• Assignment operators
• Relational operators
• Logical operators
• Bit wise operators
• Conditional operators (ternary operators)
• Increment/decrement operators
• Special Operators

You might also like